最近測試esxi6.7的vmotion功能,為了熟悉kvm決定在kvm上實(shí)現(xiàn), 系統(tǒng)是ubuntu16.04, 啟動(dòng)一個(gè)kvm,發(fā)現(xiàn)esxi在遷移時(shí)會(huì)崩潰,無法進(jìn)行遷移,查找相關(guān)次料,解決方案如下:
成都創(chuàng)新互聯(lián)于2013年創(chuàng)立,先為峰峰礦等服務(wù)建站,峰峰礦等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為峰峰礦企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
# 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: 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
當(dāng)然你也可以使用virt-manager來建立虛擬機(jī)。