virtualization-with-kvm-on-a-centos-6.4
virtualization-with-kvm-on-a-centos-6.4
异类深呼吸 发表于3年前
virtualization-with-kvm-on-a-centos-6.4
  • 发表于 3年前
  • 阅读 59
  • 收藏 3
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

摘要: 看到一篇蛮通俗易懂的,真心算是step by step的教程了,所以直接节选过来

<h2 style="margin: 1.5em 0px 1em; padding: 0.5em 0px 0px; -webkit-print-color-adjust: exact; border-width: 4px 0px 0px; border-top-style: solid; border-top-color: #e0e0e0; font-size: 20px; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 18px;">1、Preliminary Note</h2> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">看了许多文章,觉得这篇比较通俗易懂,摘抄原文地址 <a style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; color: #4183c4; text-decoration: none;" href="http://www.howtoforge.com/virtualization-with-kvm-on-a-centos-6.4-server">virtualization-with-kvm-on-a-centos-6.4-server</a></p> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">I'm using a CentOS 6.4 server with the hostname server1.example.com and the IP address 192.168.0.100 here as my KVM host.</p> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">I had SELinux disabled on my CentOS 6.4 system. I didn't test with SELinux on; it might work, but if not, you better switch off SELinux as well:</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">vi /etc/selinux/config <br />Set SELINUX=disabled... <br /><br /># enforcing - SELinux security policy is enforced. <br /># permissive - SELinux prints warnings instead of enforcing. <br /># disabled - No SELinux policy is loaded. </code></pre> <h2 style="margin: 1.5em 0px 1em; padding: 0.5em 0px 0px; -webkit-print-color-adjust: exact; border-width: 4px 0px 0px; border-top-style: solid; border-top-color: #e0e0e0; font-size: 20px; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 18px;">2、Installing KVM</h2> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">First check if your CPU supports hardware virtualization</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">egrep '(vmx|svm)' --color=always /proc/cpuinfo </code></pre> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">If nothing is displayed, then your processor doesn't support hardware virtualization, and you must stop here.</p> </blockquote> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">To install KVM and virtinst (a tool to create virtual machines)</p> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">yum install kvm libvirt python-virtinst qemu-kvm </code></pre> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">Then start the libvirt daemon:</p> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">/etc/init.d/libvirtd start </code></pre> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">To check if KVM has successfully been installed, run</p> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">virsh -c qemu:///system list </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">[root@server1 ~]# virsh -c qemu:///system list <br />Id Name State <br />---------------------------------- </code></pre> <h2 style="margin: 1.5em 0px 1em; padding: 0.5em 0px 0px; -webkit-print-color-adjust: exact; border-width: 4px 0px 0px; border-top-style: solid; border-top-color: #e0e0e0; font-size: 20px; font-family: helvetica, arial, freesans, clean, sans-serif; line-height: 18px;">3、Install bridge</h2> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">Next we need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network.</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">yum install bridge-utils </code></pre> <blockquote style="margin: 1em 0px; padding: 0px 0px 0px 0.6em; -webkit-print-color-adjust: exact; border-left-width: 5px; border-left-color: #dddddd; color: #555555; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 18px;"> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em;">and configure a bridge. Create the file /etc/sysconfig/network-scripts/ifcfg-br0 (please use the IPADDR, PREFIX, GATEWAY, DNS1 and DNS2 values from the /etc/sysconfig/network-scripts/ifcfg-eth0 file); make sure you use TYPE=Bridge, not TYPE=Ethernet:</p> </blockquote> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">vi /etc/sysconfig/network-scripts/ifcfg-br0 <br /> DEVICE="br0" <br /> NM_CONTROLLED="yes" <br /> ONBOOT=yes <br /> TYPE=Bridge <br /> BOOTPROTO=none <br /> IPADDR=192.168.0.100 <br /> PREFIX=24 <br /> GATEWAY=192.168.0.1 <br /> DNS1=8.8.8.8 <br /> DNS2=8.8.4.4 <br /> DEFROUTE=yes <br /> IPV4_FAILURE_FATAL=yes <br /> IPV6INIT=no <br /> NAME="System br0" </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">vi /etc/sysconfig/network-scripts/ifcfg-eth0<br /> DEVICE="eth0" <br /> #BOOTPROTO=none <br /> NM_CONTROLLED="yes" <br /> ONBOOT=yes <br /> TYPE="Ethernet" <br /> UUID="73cb0b12-1f42-49b0-ad69-731e888276ff" <br /> HWADDR=00:1E:90:F3:F0:02 <br /> #IPADDR=192.168.0.100 <br /> #PREFIX=24 <br /> #GATEWAY=192.168.0.1 <br /> #DNS1=8.8.8.8 <br /> #DNS2=8.8.4.4 <br /> DEFROUTE=yes <br /> IPV4_FAILURE_FATAL=yes <br /> IPV6INIT=no <br /> NAME="System eth0" <br /> BRIDGE=br0 #这里使用桥接模式 </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">/etc/init.d/network restart </code></pre> <pre style="margin: 1em 0px; padding: 5px; -webkit-print-color-adjust: exact; font-size: 12px; line-height: 18px; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; background-color: #eeeeee; border: 1px solid #dddddd; color: #444444; overflow: auto; -webkit-box-shadow: rgba(0, 0, 0, 0.0666667) 0px 1px 2px inset; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;"><code style="margin: 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: normal; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; border: none;">[root@server1 ~]# ifconfig <br />br0 Link encap:Ethernet HWaddr 00:1E:90:F3:F0:02 <br /> inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0 <br /> inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link <br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 <br /> RX packets:8 errors:0 dropped:0 overruns:0 frame:0 <br /> TX packets:27 errors:0 dropped:0 overruns:0 carrier:0 <br /> collisions:0 txqueuelen:0 <br /> RX bytes:460 (460.0 b) TX bytes:2298 (2.2 KiB) <br /><br />eth0 <br /> Link encap:Ethernet HWaddr 00:1E:90:F3:F0:02 <br /> inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link <br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 <br /> RX packets:18455 errors:0 dropped:0 overruns:0 frame:0 <br /> TX packets:11861 errors:0 dropped:0 overruns:0 carrier:0 <br /> collisions:0 txqueuelen:1000 <br /> RX bytes:26163057 (24.9 MiB) TX bytes:1100370 (1.0 MiB) <br /> Interrupt:25 Base address:0xe000 <br /></code></pre> <p style="margin: 1em 0px; padding: 0px; -webkit-print-color-adjust: exact; line-height: 1.5em; font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px;">如果能成功看到此,KVM基础环境安装就完成了,也就是这台机器上安装好了KVM套件,可以被一些虚拟化套件直接来管理这台机器,下面就应该安装一些KVM的管理工具,或者相关套件,比如virt-manager管理工具,或者convirture图形化管理等等,后期将结合covirture进行简单的一个虚拟化的生产环境的应用</p>

标签: centos 6.4 kvm 安装
共有 人打赏支持
粉丝 6
博文 46
码字总数 42368
×
异类深呼吸
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: