一、YUM安装KVM
yum groupinstall -y "GNOME Desktop" qemu-kvm qemu-kvm-tools virt-install qemu-img bridge-utils libvirt virt-manager
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
验证
cat /proc/cpuinfo | grep vmx
lsmod | grep kvm
systemctl start libvirtd
systemctl enable libvirtd
二、设置KVM网络
vim /etc/sysconfig/network-scripts/ifcfg-ens33
...
BRIDGE=br0
vim /etc/sysconfig/network-scripts/ifcfg-br0
TYPE=Bridge
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.107.200
NETMASK=255.255.255.0
GATEWAY=192.168.107.2
systemctl restart network
三、KVM管理
virt-manager
virsh -h
ls /etc/libvirt/qemu
virsh list -all
virsh shutdown test01
virsh start test01
virsh destroy test01
virsh create /etc/libvirt/qemu/test01.xml
virsh suspend test01
virsh resume test01
virsh autostart test01
virsh dumpxml test01 > /etc/libvirt/qemu/test02.xml
virsh undefine test01
virsh define test01.xml
virsh edit test01
文件管理
qemu-img info /data_kvm/store/test01.qcow2
qemu-img convert -f raw -O qcow2 /data_kvm/store/test01.img /data_kvm/store/test01.qcow2
virsh edit test01
yum -y install libguestfs-tools-c
virt-edit -a /data_kvm/store/test01.qcow2 /etc/resolv.conf
virt-df -h test01
virt-clone -o test01 -n test02 -f /data_kvm/store/test02.qcow2
快照
virsh snapshot-create test01
virsh snapshot-current test01
virsh snapshot-list test01
virsh snapshot-revert test01 1503494464
virsh snapshot-delete test01 1503494464