准备xml文件:
查看当前虚拟机列表:
[root@controller1 ~]# virsh list --all
Id Name State
----------------------------------------------------
- instance-00000073 shut off
使用demo.xml创建新的虚拟机
[root@controller1 ~]# virsh define demo.xml
Domain demo defined from demo.xml
[root@controller1 ~]# virsh list --all
Id Name State
----------------------------------------------------
7 demo running
- instance-00000073 shut off
[root@controller1 ~]# virsh start demo
Domain demo started
[root@controller1 ~]# ps -auxf |grep qemu
root 10448 0.0 0.0 112640 976 pts/1 S+ 10:55 0:00 \_ grep --color=auto qemu
root 10110 27.0 1.1 923984 94096 ? Sl 10:55 0:05 /usr/libexec/qemu-kvm -name demo -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -m 512 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid b957acd3⑶777⑷b9d-b3b5-f4a59849e455 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-demo/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/root/cirros.img,if=none,id=drive-ide0-0-0,format=qcow2 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -drive file=/root/cirros.img,if=none,id=drive-ide0-0⑴,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0⑴,id=ide0-0⑴ -vnc 0.0.0.0:0 -k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -msg timestamp=on
[root@controller1 ~]# ls
遇到的问题:主机内存不足:
主机还有多少内存
这里是1台控制节点,甚么虚拟机都不起,4G的内存也基本用完了
所以,控制节点内存需要大于4G,否则1台虚拟机都开启不了
[root@controller1 ~]# free -h
total used free shared buffers cached
Mem: 3.6G 3.4G 201M 229M 45M 154M
-/+ buffers/cache: 3.2G 401M
Swap: 0B 0B 0B
[root@controller1 ~]#
如果给虚拟机512M内存,这里会报错:
Cannot set up guest memory 'pc.ram': Cannot allocate memory