1.检查cpu是否支持硬件虚拟化
egrep -c '(vmx|svm)' /proc/cpuinfo
如果不支持
2.配置ali yum源,然后安装kvm
(1)#yum install qemu-kvm virt-manager libvirt libvirt-python python-virtinst bridge-utils
3.分配磁盘,用于快照
先创建#mkdir -p /kvmtest/centos-6.5.qcow2 ,上传文件到目录下
再执行
[root@h18 kvmtest]# ls
CentOS-6.5-x86_64-minimal.iso
[root@h18 kvmtest]# qemu-img create -f qcow2 rhel6test.img 10G
Formatting 'rhel6test.img', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536
设置启动
#service libvirtd start //开启libvirtd服务
#chkconfig libvirtd on //开机启动
[root@h18 kvmtest]# 执行命令启动kvm
virt-install --virt-type kvm --name centos-6.5 --ram 1024 \
--vcpus 1 \
--cdrom=/kvmtest/CentOS-6.5-x86_64-minimal.iso \
--disk /kvmtest/rhel6test.img,format=qcow2 \
--network network=default \
--graphics vnc,listen=0.0.0.0 --noautoconsole \
--os-type=linux --os-variant=rhel6
启动成功后,查看虚拟机占用端口:5900
一般查看端口是否能访问用命令:telnat 192.168.142.115:8080
4、在linux下安装虚拟机
需要使用工具:
通过链接:h18的ip,进行远程安装linux
默认选择----》选择分区
根分区10个g都用完
然后默认,选择yes,下一步等待安装完成
5、使用命令
#virsh
重启命令
6、进入虚拟机,然后为其创建网卡
再重启网络:service network restart
如果失败,那么修改
#vi /etc/sysconfig/network
#vi /etc/udev/rules.d/70-presisent-network.rules
配置完成后,查看虚拟机里面的虚拟机ip:192.168.122.111
再在xshell里面ping该机器,确认是否正常
确认能ping通外网
7、给eth005搭建yum源阿里源
文件内容
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
清空缓存
#yum clean all
生成缓存
#yum makecache