apple 2012-8-9 17:40
CentOS 6 install 安裝 kvm 虛擬機器
<span id="ctl00_ContentPlaceHolder1_lbFmyWodCon">之前就想玩看看 Linux 上的Virtual Machine,現在CentOS 6.0 以上的版本已經改用 KVM(Kenral base Virtrual Machine),在安裝上似乎是非常簡單的。下面是一些安裝心得跟大家分享討論~~</span><div><span><br></span></div><div><div class="audience"><div class="audience"><p>安裝KVM 之主機必須支援 CPU 虛擬化技術,如 AMD 的 AMD-V 或是 Intel 的 VT-x。</p><p><br></p>
<p>進入終端機後,輸入以下指令</p><p>[quote]</p>
<p>egrep -c '(vmx|svm)' /proc/cpuinfo</p>
<p>[/quote]</p><p>若輸出為 0 則代表不支援;反之若輸出為 1 以上則代表主機支援 CPU 虛擬化技術。</p></div><div class="audience"><br></div><div class="audience">安裝kvm、網路橋接套件:</div><div class="no-overflow"><div class="text_to_html"># yum install kvm virt-manager libvirt bridge-utils<br>
# lsmod | grep kvm <br>
# service libvirtd start</div><div class="text_to_html"><br></div><div class="text_to_html"><img src="http://www.techotopia.com/images/3/34/Rhel6_virt_machine_manager.jpg" border="0"><br></div><div class="text_to_html"><br></div><div class="text_to_html">至於要如何在KVM 上面安裝一個新的OS...直接參考這篇教學比較快囉~~</div><div class="text_to_html"><a href="http://www.techotopia.com/index.php/Creating_an_RHEL_6_KVM_Virtual_Machine" target="_blank">http://www.techotopia.com/index.php/Creating_an_RHEL_6_KVM_Virtual_Machine</a></div><div class="text_to_html"><br></div><div class="text_to_html"><div class="text_to_html">##設定網路的橋接功能</div><div class="text_to_html"><br></div><div class="text_to_html"> 建立橋接網卡</div><div class="text_to_html"> 進入/etc/sysconfig/network-scripts/目錄,複製ifcfg-eth0成ifcfg-br0</div><div class="text_to_html"> 修改ifcfg-br0中的device和type的資料</div><div class="text_to_html"> =================================</div><div class="text_to_html"> DEVICE=br0 (原為eth0)</div><div class="text_to_html"> BOOTPROTO=none</div><div class="text_to_html"> HWADDR=xx:xx:xx:xx:xx:xx</div><div class="text_to_html"> ONBOOT=yes</div><div class="text_to_html"> NETMASK=xxx.xxx.xxx.xxx</div><div class="text_to_html"> IPADDR=xxx.xxx.xxx.xxx</div><div class="text_to_html"> GATEWAY=xxx.xxx.xxx.xxx</div><div class="text_to_html"> TYPE=Bridge (原為Ethernet)</div><div class="text_to_html"> =================================</div><div class="text_to_html"> 修改ifcfg-eth0的資料</div><div class="text_to_html"> =================================</div><div class="text_to_html"> DEVICE=eth0</div><div class="text_to_html"> #BOOTPROTO=none (加上註解)</div><div class="text_to_html"> HWADDR=xx:xx:xx:xx:xx:xx</div><div class="text_to_html"> ONBOOT=yes</div><div class="text_to_html"> #NETMASK=xxx.xxx.xxx.xxx (加上註解)</div><div class="text_to_html"> #IPADDR=xxx.xxx.xxx.xxx (加上註解)</div><div class="text_to_html"> #GATEWAY=xxx.xxx.xxx.xxx (加上註解)</div><div class="text_to_html"> #TYPE=Ethernet (加上註解)</div><div class="text_to_html"> BRIDGE=br0 (加上這一行)</div><div class="text_to_html"> =================================</div><div class="text_to_html"> 開啟IP forwarding,讓guest可以和host相通,修改/etc/sysctl.conf,</div><div class="text_to_html"> 設定net.ipv4.ip_forward = 1</div><div class="text_to_html"><br></div><div class="text_to_html"> 重新啟動網路:/etc/init.d/network restart</div><div><br></div><div>這樣裝好之後...就可以使用 Bridge Mode囉~~</div></div></div></div></div>