The kernel component of KVM is included in mainline Linux, as of 2.6.20.
1、查看系統是否硬體虛擬化
# egrep 'vmx|svm' /proc/cpuinfo
2. 安裝KVM及其組件
yum -y install qemu-kvm libvirt python-virtinst bridge-utils virt-manager
yum groupinstall Virtualization
yum groupinstall "Virtualization Platform"
# lsmod | grep kvm
# /etc/init.d/libvirtd restart
建立橋接
cp ifcfg-eth0 ifcfg-br0
# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:1d:09:66:e1:f8
IPV6INIT=no
MTU=1500
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
UUID="dacbb334-5792-4969-889a-907245adbd80"
IPADDR=192.168.100.210
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
DNS1=8.8.8.8
USERCTL=no
BRIDGE=br0 ###添加關鍵一行
# cat ifcfg-br0
DEVICE=br0 ###修改關鍵行
BOOTPROTO=none
HWADDR=00:1d:09:66:e1:f8
IPV6INIT=no
MTU=1500
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Bridge ###修改關鍵行
UUID="dacbb334-5792-4969-889a-907245adbd80"
IPADDR=192.168.100.210
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
DNS1=8.8.8.8
USERCTL=no
問題:
使用kvm複製的虛機把源機的mac地址也一併複製了,在啟動複製機時,網卡無法啟用,提示如下:
device eth0 does not seem to be present,delaying initialization
原因:因mac地址重複,複製機把eth0重新命名成eth1了
解決:
1、列出識別的當前網卡列表
# ls /sys/class/net
eth1 lo
2、刪除第一條SUBSYSTEM,把原第二條SUBSYSTEM的NAME="eth1"修改為NAME="eth0"
#vim /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
3、修改網卡eth0的設定檔的mac地址HWADDR為修改後70-persistent-net.rules中的mac地址
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
4、reboot.
參考:http://www.ryanchapin.com/fv-b-4-655/Cloned-VMware-CentOS6-Server-and--quot-device-eth0-does-not-seem-to-be-present--delaying-initialization-
quot--Error-.html