最近測試esxi6.7的vmotion功能,爲了熟悉kvm決定在kvm上實現, 系統是ubuntu16.04, 啓動一個kvm,發現esxi在遷移時會崩潰,沒法進行遷移,查找相關次料,解決方案以下:shell
# apt install qemu-system-x86 qemu-kvm qemu libvirt-bin virt-manager virtinst bridge-utils cpu-checker virt-viewer
# kvm-ok INFO: /dev/kvm exists KVM acceleration can be used
# virt-host-validate QEMU: Checking for hardware virtualization : PASS QEMU: Checking if device /dev/kvm exists : PASS
cat /etc/group | grep libvirt | awk -F':' {'print $1'} | xargs -n1 sudo adduser $USER # add user to kvm group also sudo adduser $USER kvm # relogin, then show group membership exec su -l $USER id | grep libvirt
# ip addr show virbr0 17: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:d2:52:b5 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever
# iptable -t nat -vnL Chain POSTROUTING (policy ACCEPT 146 packets, 11359 bytes) pkts bytes target prot opt in out source destination 0 0 RETURN all -- * * 192.168.122.0/24 224.0.0.0/24 0 0 RETURN all -- * * 192.168.122.0/24 255.255.255.255 0 0 MASQUERADE tcp -- * * 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535 0 0 MASQUERADE udp -- * * 192.168.122.0/24 !192.168.122.0/24 masq ports: 1024-65535 0 0 MASQUERADE all -- * * 192.168.122.0/24 !192.168.122.0/24
# virsh pool-list --all Name State Autostart ------------------------------------------- default active yes $ virsh pool-define-as kvmpool --type dir --target /data/kvm/pool Pool kvmpool defined $ virsh pool-list --all $ virsh pool-start kvmpool $ virsh pool-autostart kvmpool $ virsh pool-list --all Name State Autostart ------------------------------------------- default active yes kvmpool active yes
virt-install --virt-type=kvm --name=ukvm1404 --ram 1024 --vcpus=1 --virt-type=kvm --hvm --cdrom ~/Downloads/mini.iso --network network=default --graphics vnc --disk pool=default,size=20,bus=virtio,format=qcow2 --noautoconsole # open console to VM virt-viewer ukvm1404
virsh destroy ukvm1404 virsh undefine ukvm1404
# vi /etc/modprobe.d/qemu-system-x86.conf options kvm_intel nested=1 enable_apicv=n options kvm ignore_msrs=1
# want Y to be returned $ cat /sys/module/kvm/parameters/ignore_msrs # want N to be returned $ cat /sys/module/kvm_intel/parameters/enable_apicv # want Y to be returned $ cat /sys/module/kvm_intel/parameters/nested
# virt-install --virt-type=kvm --name=esxi4 \ --ram 4096 --vcpus=4 \ --virt-type=kvm --hvm \ --cdrom /data/iso/VMware-VMvisor-Installer-6.7.0.update03-14320388.x86_64.iso \ --network network:default,model=e1000 \ --graphics vnc --video qxl \ --disk pool=default,size=80,sparse=true,bus=ide,format=qcow2 \ --boot cdrom,hd --noautoconsole --force \ --cpu host-model-only 固然你也能夠使用virt-manager來創建虛擬機。