1.安裝KVM內核及libvirtd相關組件python
yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer
2.加載KVM運行模塊bash
[root@localhost ~]# modprobe kvm [root@localhost ~]# modprobe -ls |grep kvm kernel/arch/x86/kvm/kvm.ko kernel/arch/x86/kvm/kvm-intel.ko kernel/arch/x86/kvm/kvm-amd.ko
3.建立物理橋網絡
virsh iface-bridge eth0 br0 查看網絡 [root@localhost ~]# ifconfig br0 Link encap:Ethernet HWaddr 00:0C:29:C1:62:56 inet addr:192.168.150.136 Bcast:192.168.150.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fec1:6256/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4925 errors:0 dropped:0 overruns:0 frame:0 TX packets:3937 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:532933 (520.4 KiB) TX bytes:13484199 (12.8 MiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:C1:62:56 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:377686 errors:0 dropped:0 overruns:0 frame:0 TX packets:110643 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:507725096 (484.2 MiB) TX bytes:66233641 (63.1 MiB)
4.建立一塊虛擬磁盤:ide
qemu-img create -f qcow2 /kvm/test003.img 5G
5.建立一個虛擬機:orm
qcow2格式 [root@localhost ~]# virt-install --name test003 --ram 512 \ --vcpus=1 --disk path=/kvm/test003.img,size=5,format=qcow2,bus=virtio \ --accelerate --cdrom /tmp/CentOS-6.6-x86_64-minimal.iso\ --vnc --vncport=5910 --vnclisten=0.0.0.0\ --network bridge=br0,model=virtio --noautoconsole raw格式: [root@localhost ~]# virt-install --name test003 --ram 512 \ --vcpus=1 --disk path=/kvm/test003.img,size=5,bus=virtio \ --accelerate --cdrom /tmp/CentOS-6.6-x86_64-minimal.iso\ --vnc --vncport=5910 --vnclisten=0.0.0.0\ --network bridge=br0,model=virtio --noautoconsole
6.VNC鏈接blog