1. 程式人生 > >#Centos7.4#Linux虛擬機器KVM配置CPU、記憶體

#Centos7.4#Linux虛擬機器KVM配置CPU、記憶體

【修改kvm虛擬機器的資源大小cpu、記憶體、硬碟】

# virsh list --all 

Id    Name         State
-------------------------------------------------
-     bbotte       shut off 
   
# virsh setvcpus bbotte --maximum 4 --config
# virsh setmaxmem bbotte 1048576 --config

# virsh dominfo bbotte
Id:             2
Name:           bbotte
UUID:           bd22f444-ee7f-7f00-3d1b-1bb0d0857e43
OS Type:        hvm
State:          running
CPU(s):         4
CPU time:       152.3s
Max memory:     1048576 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: none
Security DOI:   0
   ####修改xml配置檔案###

1、virsh edit centos73 (更改前要將virsh shutdown centos73 )
找到“memory”和“vcpu”標籤,將
<name>centos73</name> <uuid>2220a6d1-a36a-4fbb-8523-e078b3dfe795</uuid> <memory unit='KiB'>2097152</memory> <currentMemory unit='KiB'>2097152</currentMemory> <vcpu placement='static'>1</vcpu> 改為: <name>centos73</name> <uuid>2220a6d1-a36a-4fbb-8523-e078b3dfe795</uuid> <memory unit='KiB'>3145728</memory> <currentMemory unit='KiB'>3145728</currentMemory> <vcpu placement='static'>2</vcpu> virsh define /etc/libvirt/qemu/centos73.xml 重定義使配置生效 重啟虛擬機器 virsh start centos73 --console 檢視原配置資訊 [
[email protected]
kvm]# virsh dominfo centos734 Id: - Name: centos73 UUID: 2220a6d1-a36a-4fbb-8523-e078b3dfe795 OS Type: hvm State: shut off CPU(s): 1 Max memory: 2097152 KiB Used memory: 2097152 KiB Persistent: yes Autostart: disable Managed save: no Security model: none Security DOI: 0 調整後資訊: [[email protected] kvm]# virsh dominfo centos73 Id: - Name: centos73 UUID: 2220a6d1-a36a-4fbb-8523-e078b3dfe795 OS Type: hvm State: shut off CPU(s): 2 Max memory: 3145728 KiB Used memory: 3145728 KiB Persistent: yes Autostart: disable Managed save: no Security model: none Security DOI: 0

參考連線:

https://blog.csdn.net/hnhuangyiyang/article/details/50902223