下载CentOS6.8
在阿里云镜像站下载CentOS6.8操作系统:
https://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD1.iso
https://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD2.iso
https://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD1to2.torrent
https://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.iso
https://mirrors.aliyun.com/centos/6.8/isos/x86_64/CentOS-6.8-x86_64-minimal.torrent
安装虚拟机
- VMware中新建虚拟机,这里第一步选择稍后安装操作系统。之后的过程比较简单,这里不再赘述。
- 安装CentOS操作系统,这里也是按照提示一步一步安装好就行了,一般不会有问题。
遇到的问题:
- 使用简易安装CentOS 最小化安装包时,在安装VMware Tools时会出错:
installing VMware Tools, Please wait...
mount: special device /dev/had does not exit
mount: block device /dev/sr0 is write-protected,mounting read-only
解决办法1:不使用简易安装,新建虚拟机时选择稍后安装操作系统。
- 安装过程中出错:
The CentOS disc was not found in any of your CDROM drives. Please insert the CentOS disc and press OK to retry.
解决办法:菜单栏选择虚拟机->可移动设备->CD/DVD(IDE)->连接
安装VMware-tools
- 先在VMware 菜单栏选择虚拟机->安装VMware Tools
- 挂载光驱
mount -o ro /dev/cdrom /media
- 拷贝光驱中的文件到/tmp目录,解压缩后进行安装
[root@CentOS /]# cd /media
[root@CentOS /]# cp ./VMwareTools-10.0.6-3595377.tar.gz /tmp
[root@CentOS /]# cd /tmp
[root@CentOS tmp]# tar -zxvf ./VMwareTools-10.0.6-3595377.tar.gz
[root@CentOS tmp]# cd ./vmware-tools-distrib
[root@CentOS vmware-tools-distrib]# ./vmware-install.pl
然后按照提示安装即可。
出现过的问题:
/usr/bin/perl:bad interpreter:No such file or directory.
这是因为CentOS最小化安装时,没有安装Perl环境,需要使用yum groupinstall “Perl Support”来安装Perl。
安装open-vm-tools
CentOS7之后已经有带一个open-vm-tools,这是为了简化安装流程做的open source版本,所以CentOS7之后版本要安装VMware Tools直接使用下列指令就可以了。
yum -y install open-vm-tools
配置网络
使用NAT模式连接网络
- 主机配置共享网络
可能出现的问题
Internet 连接共享访问被启用时,出现了一个错误。
Internet connection Sharing cannot be enabled. A LAN connection is already configured with the IP address that is required for automatic IP addressing.
解决办法:把VMnet8的ip设置为自动获取或者设为192.168.0.1,然后重新设置共享。
- 虚拟机配置网络接口信息:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR=00:0c:29:A3:55:F1
TYPE=Ethernet
UUID=b47dcb09-98cc-4eaf-893e-0020ac444f07
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.137.10
NETMASK=255.255.255.0
GATEWAY=192.168.137.2
DNS1=114.114.114.114
IPV6INIT=no
USERCTL=no
ARPCHECK=no
- 重启网络服务
service network restart
配置端口转发
此时主机能与虚拟机互通,但虚拟机与局域网其他主机不能连通,于是做一个端口转发
更换软件源
将CentOS的yum源更换为国内的阿里云源
- 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 运行yum makecache生成缓存
yum clean all
yum makecache
安装EPEL源
(一)手动安装
- 查看现有的源:
yum repolist
安装EPEL源
- 打开 http://mirrors.kernel.org/fedora-epel/
- 根据对应版本选择相应安装包,我的版本是6.8 final,所以我选择 http://mirrors.kernel.org/fedora-epel/epel-release-latest-6.noarch.rpm
- 安装命令:
rpm -Uvh http://mirrors.kernel.org/fedora-epel/epel-release-latest-6.noarch.rpm
可能出现的问题
curl: (6) Couldn't resolve host 'mirrors.kernel.org'
error: skipping http://mirrors.kernel.org/fedora-epel/epel-release-latest-6.noarch.rpm - transfer failed
原因可能是DNS服务器解析失败。修改/etc/resolv.conf
添加一个DNS服务器
vi /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 223.5.5.5
nameserver 8.8.8.8
(二)命令安装
yum -y install epel-release
yum repolistroot
相关链接
http://www.jianshu.com/p/99927be43a04
http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD