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