|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!RHEL6已推出好久了,没想到在RedHat自家的RHEL6上装置KVM另有这么多成绩,岂非不该该是像Apache/MySQL那样装置完就能够用的么?(注:撤除商标,CentOS就是RHEL,CentOS6和RHEL6是一回事)。以下操纵在CentOS6.2最小化装置版本CentOS-6.2-x86_64-minimal.iso上完成,其他版本大概不会碰到本文提到的局部成绩。
反省CPU
和Xen分歧,KVM必要有CPU的撑持(IntelVT或AMDSVM),在装置KVM之前反省一下CPU是不是供应了假造手艺的撑持:
#egrep(vmx|svm)--color=always/proc/cpuinfo
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidanonstop_tscaratpnimonitords_cplvmxsmxesttm2ssse3cx16xtprsse4_1sse4_2popcntlahf_lm
装置KVM
装置KVM很简单,要一般运转的话还必要折腾一下:
#yum-yinstallqemu-kvmlibvirtpython-virtinstbridge-utils
装置完后封闭selinux偏重启体系,然后确认一下是不是kvm装置乐成:
#vi/etc/sysconfig/selinux
SELINUX=disabled
#reboot
#lsmod|grepkvm
kvm_intel504123
kvm3059881kvm_intel
#stat/dev/kvm
File:`/dev/kvm
Size:0Blocks:0IOBlock:4096characterspecialfileDevice:5h/5dInode:10584Links:1Devicetype:a,e8Access:(0666/crw-rw-rw-)Uid:(0/root)Gid:(36/kvm)
Access:2012-04-1816:00:46.276341129+0200
Modify:2012-04-1816:00:46.276341129+0200
Change:2012-04-1816:00:46.276341129+0200
再来确认一下libvirt是不是能一般启动和封闭。重启libvirtd办事的话会报错,检察日记发明internalerrorFailedtocreatemDNSclient毛病,这个成绩简单更正,装置avahi便可,也能够往/etc/libvirt/libvirtd.conf设置mdns_adv=0,这里接纳装置avahi的***:
#/etc/init.d/libvirtdrestart
Stoppinglibvirtddaemon:[FAILED]
Startinglibvirtddaemon:[OK]
#tail/var/log/libvirt/libvirtd.log
2012-04-1813:51:03.032+0000:18149:info:libvirtversion:0.9.4,package:23.el6_2.7CentOSBuildSystem,2012-04-16-14:12:59,c6b5.bsys.dev.centos.org)
2012-04-1813:51:03.032+0000:18149:error:virNetServerMDNSStart:460:internalerrorFailedtocreatemDNSclient:Daemonnotrunning
#yum-yinstallavahi
#/etc/init.d/messagebusrestart
#/etc/init.d/avahi-daemonrestart
重启libvirtd办事持续报错,发明短少dmidecode包,装置dmidecode后终究重启libvirtd乐成:
#/etc/init.d/libvirtdrestart
Stoppinglibvirtddaemon:[FAILED]
Startinglibvirtddaemon:[OK]
#tail/var/log/libvirt/libvirtd.log
2012-04-1813:54:54.654+0000:18320:info:libvirtversion:0.9.4,package:23.el6_2.7(CentOSBuildSystem,2012-04-16-14:12:59,c6b5.bsys.dev.centos.org)
2012-04-1813:54:54.654+0000:18320:error:virSysinfoRead:465:internalerrorFailedtofindpathfordmidecodebinary
#yum-yinstalldmidecode
#/etc/init.d/libvirtdrestart
Stoppinglibvirtddaemon:[OK]
Startinglibvirtddaemon:[OK]
如今kvm和libvirt都装置乐成和运转了,但其实不暗示可用了,成绩接着来。
设置收集桥接
桥接收集设置文件,从ifcfg-eth0复制现有网卡的设置文件,更名为ifcfg-br0:
cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-br0
修正ifcfg-br0,注重白色的两行,其他局部基础上不必改。
vi/etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
BROADCAST=192.168.200.255
IPADDR=192.168.200.180
NETMASK=255.255.255.0
NETWORK=192.168.200.0
ONBOOT=yes
修正ifcfg-br0,注重白色的行,其他局部基础上不必改。
vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=
ONBOOT=yes
BRIDGE=br0
#BOOTPROTO=static
#BROADCAST=192.168.200.255
#IPADDR=192.168.200.180
#NETMASK=255.255.255.0
#NETWORK=192.168.200.0
重启network办事
servicenetworkrestart
这里必要注重,假如启用了NetworkManager,最好封闭该办事,由于该办事与network有抵触。
设置转发
实行以下下令:
echo1>/proc/sys/net/ipv4/ip_forward
这一步固然只要复杂的一条下令,但却很关头。假如不实行这一步,一切的假造机将没法上彀。别的,上一步设置完桥接以后重启network,会主动将ip_forward改成0,以是从头设置收集后,不要忘了实行该下令。发明假造机没法上彀的时分,也能够反省一下ip_forward值。
装置假造机
从6系列入手下手RedHat保举利用virt-install/virsh系列工具操纵kvm,而不是间接利用qemu-kvm,以是qemu-kvm被移到一个不起眼的中央/usr/libexec/:
#qemu-kvm-bash:qemu-kvm:commandnotfound#ls/usr/libexec/qemu-kvm/usr/libexec/qemu-kvm
VPSee接纳RedHat保举的体例(virt-install)装置假造机,这里以装置ubuntu-11.10-server-amd64.iso为例:
#virt-install
--nameubuntu
--ram512
--vcpus=1
--diskpath=/root/ubuntu.img,size=10
--accelerate
--cdrom/root/ubuntu-11.10-server-amd64.iso
--graphicsvnc
入手下手装置,创立硬盘ubuntu.img后就报错,用的是root帐号竟然还Permissiondenied?!
Startinginstall...Creatingstoragefileubuntu.img|10.0GB00:00ERRORinternalerrorProcessexitedwhilereadingconsolelogoutput:chardeviceredirectedto/dev/pts/1qemu-kvm:-drivefile=/root/ubuntu.img,if=none,id=drive-ide0-0-0,format=raw,cache=none:couldnotopendiskimage/root/ubuntu.img:Permissiondenied
Domaininstallationdoesnotappeartohavebeensuccessful.Ifitwas,youcanrestartyourdomainbyrunning:virsh--connectqemu:///systemstartubuntuotherwise,pleaserestartyourinstallation.
修正qemu.conf设置,把上面几个中央的正文往失落,然后把dynamic_ownership的值改成0,克制libvirtd静态修正文件的回属:
#vi/etc/libvirt/qemu.conf
...
user="root"
group="root"
dynamic_ownership=0
...
重启libvirtd办事再用下面的virt-install下令装置就应当能够了。这个时分vnc默许绑定的是本机127.0.0.1,假如其他呆板想用vnc客户端会见这台kvm办事器正在装置的ubuntu的话必要把vnc绑定到办事器的IP地点大概绑定到全局0.0.0.0.修正qemu.conf文件作废vnc_listen一行后面的正文,记得重启libvirtd:
#vi/etc/libvirt/qemu.conf
...
vnc_listen="0.0.0.0"
...
在CentOS5.x装置KVM能够看:在CentOS5上装置和设置KVM
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们! |
|