最近测试esxi6.7的vmotion功能,为了熟悉kvm决定在kvm上实现, 系统是ubuntu16.04, 启动一个kvm,发现esxi在迁移时会崩溃,无法进行迁移,查找相关次料,解决方案如下:
# 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来建立虚拟机。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。