First, turn down the virtual machine memory
Turn down the virtual machine memory can be dynamically realized without shutdown
1. View the current memory size
[root@heyong kvm]# virsh dominfo test
Id: 7
名称: test
UUID: 8f2bb4b7-c7ed-31aa-3676-9fb04923163d
OS 类型: hvm
状态: running
CPU: 4
CPU 时间: 3985.0s
最大内存: 12024832 KiB
使用的内存: 12024000 KiB
持久: 否
自动启动: 禁用
管理的保存: 否
安全性模式: none
安全性 DOI: 0
or
[root@heyong kvm]# virsh dominfo test|grep 内存
最大内存: 12024832 KiB
使用的内存: 12024000 KiB
2. Set the virtual machine memory size is 4G
[root@heyong ~]# virsh setmem test 4097152
3. again to view the current memory size
[root@heyong kvm]# virsh dominfo test|grep 内存
最大内存: 4098048 KiB
使用的内存: 4097152 KiB
Second, increasing the number of virtual machine CPU and memory
Increase the virtual machine memory, increase the number of virtual machines need to shut down the virtual machine CPU
1. Turn off the virtual machine
[root@heyong kvm]# virsh shutdown test
2. Edit the virtual machine configuration file
Modify the memory size, the number of CPU
[root@heyong kvm]# virsh edit test
<domain type='kvm'>
<name>test</name>
<uuid>619066ac-c7b9-4d99-9b48-560112520890</uuid>
<memory unit='KiB'>4097152</memory>
<currentMemory unit='KiB'>4097152</currentMemory>
<vcpu placement='static'>2</vcpu>
....
3. Start the virtual machine from a configuration file
[root@heyong kvm]# virsh create /etc/libvirt/qemu/test.xml
4. Review the current memory size
[root@heyong kvm]# virsh dominfo test|grep 内存
最大内存: 4098048 KiB
使用的内存: 4097152 KiB
5. Set the memory size of 6G
[root@heyong ~]# virsh setmem test 6048432
6. Verify
View the current memory size
[root@heyong ~]# virsh dominfo test | grep 内存
最大内存: 6048432 KiB
使用的内存: 6048432 KiB
View the current number of CPU
[root@heyong kvm]# virsh dominfo test|grep CPU
CPU: 2
CPU 时间: 37.6s