KVM virtual machine memory in CentOS7.6, CPU adjustment

KVM virtual machine memory and CPU adjustment in CentOS7.6

1. Reduce the virtual machine memory

Reduce the virtual machine memory It can be implemented dynamically without shutting down

1. View the current memory size

[[emailprotected ] kvm]# virsh dominfo test
Id: 7
Name: test
UUID: 8f2bb4b7-c7ed-31aa-3676-9fb04923163d
OS type: hvm
Status: running
CPU: 4
CPU time: 3985.0s
Maximum memory: 12024832 KiB
Memory used: 12024000 KiB
Lasting: No
Automatic start: disabled
Managed preservation: No
Security mode: none
Security DOI: 0

or

[[emailprotected] kvm ]# virsh dominfo test|grep memory
Maximum memory: 12024832 KiB
Memory used: 12024000 KiB

  

2. Set the virtual machine memory size to 4G

[[email Protected] ~]# virsh setmem test 4097152

  

3. Check the current memory size again

[[email Protected] kvm]# virsh dominfo test|grep memory
Maximum memory: 4098048 KiB
Memory used: 4097152 KiB

  

Second, increase the virtual machine memory and the number of CPUs

Increase the virtual machine memory and increase the number of virtual machine CPUs. Shut down the virtual machine

1. Shut down the virtual machine

[[emailprotected] kvm]# virsh shutdown test

  

2. Edit the virtual machine configuration file

Modify the memory size and the number of CPUs

[[email protected] kvm]# virsh edit test


  test
  619066ac-c7b9-4d99-9b48-560112520890
  4097152
  4097152
  2
....

  

3. Start the virtual machine from the configuration file

[[email Protected] kvm]# virsh create /etc/libvirt/qemu/test.xml

  

4. Check the current memory size

[[email Protected] kvm]# virsh dominfo test|grep memory
Maximum memory: 4098048 KiB
Memory used: 4097152 KiB

  

5. Set the virtual machine memory size to 6G

[[email Protected] ~]# virsh setmem test 6048432

  

6. Verification

Check the current memory size

[[email protected] ~]# virsh dominfo test | grep memory
Maximum memory: 6048432 KiB
Used memory: 6048432 KiB

  

View the current number of CPUs

[[emailprotected] kvm]# virsh dominfo test|grep CPU
CPU: 2
CPU time: 37.6s

[[emailprotected] kvm]# virsh dominfo test
Id: 7
Name: test
UUID: 8f2bb4b7-c7ed-31aa-3676-9fb04923163d
OS type: hvm
Status: running
CPU: 4
CPU time: 3985.0s
Maximum memory: 12024832 KiB
Memory used: 12024000 KiB
Lasting: No
Automatic start: disabled
Managed preservation: No
Security mode: none
Security DOI: 0

[[emailprotected] kvm]# virsh dominfo test|grep memory
Maximum memory: 12024832 KiB
Memory used: 12024000 KiB

[[email protected] ~]# virsh setmem test 4097152

[[email protected] kvm]# virsh dominfo test|grep memory
Maximum memory: 4098048 KiB
Memory used: 4097152 KiB

[[email protected] kvm]# virsh shutdown test

[[email protected] kvm]# virsh edit test


  test
  619066ac-c7b9-4d99-9b48-560112520890
  4097152
  4097152
  2
....

[[emailprotected] kvm]# virsh create /etc/libvirt/qemu/test.xml

[[email protected] kvm]# virsh dominfo test|grep memory
Maximum memory: 4098048 KiB
Memory used: 4097152 KiB

[[email protected] ~]# virsh setmem test 6048432

[[email protected] ~]# virsh dominfo test | grep memory
Maximum memory: 6048432 KiB
Used memory: 6048432 KiB

[[emailprotected] kvm]# virsh dominfo test|grep CPU
CPU: 2
CPU time: 37.6s

Leave a Comment

Your email address will not be published.