1. 程式人生 > >CentOS7.1 KVM虛擬化之虛擬機器記憶體、CPU調整

CentOS7.1 KVM虛擬化之虛擬機器記憶體、CPU調整

一、調小虛擬機器記憶體

調小虛擬機器記憶體可以動態實現,不用關機

1.檢視當前記憶體大小

[plain] view plain copy
[[email protected] ~]# virsh dominfo vm1-clone | grep memory
Max memory: 786432 KiB
Used memory: 786432 KiB

2.設定虛擬機器記憶體大小為512MB

[plain] view plain copy
[[email protected] ~]# virsh setmem vm1-clone 524288

3.再次檢視當前記憶體大小

[plain] view plain copy
[[email protected] ~]# virsh dominfo vm1-clone | grep memory
Max memory: 786432 KiB
Used memory: 524288 KiB

二、增大虛擬機器記憶體、增加虛擬機器CPU個數

增大虛擬機器記憶體、增加虛擬機器CPU個數需要首先關機虛擬機器

1.關閉虛擬機器

[plain] view plain copy
virsh shutdown vm1-clone

2.編輯虛擬機器配置檔案

修改記憶體大小、vcpu個數
[plain] view plain copy
virsh edit vm1-clone
……
1048432
1048432
2
……

3.從配置檔案啟動虛擬機器

[plain] view plain copy
virsh create /etc/libvirt/qemu/vm1-clone.xml

4.檢視當前記憶體大小

[plain] view plain copy
[[email protected] ~]# virsh dominfo vm1-clone | grep memory
Max memory: 1048432 KiB
Used memory: 524288 KiB

5.設定虛擬機器記憶體大小為1G

[plain] view plain copy
[[email protected] ~]# virsh setmem vm1-clone 1048432

6.驗證

檢視當前記憶體大小
[plain] view plain copy
[[email protected] ~]# virsh dominfo vm1-clone | grep memory
Max memory: 1048432 KiB
Used memory: 1048432 KiB
檢視當前CPU個數
[plain] view plain copy
[[email protected] ~]# virsh dominfo vm1-clone | grep CPU
CPU(s): 2
CPU time: 15.0s