KVM主機動態更改cpu數量和內存大小

KVM主機動態更改cpu數量和內存大小bash

關機狀態下設置最大cpu顆數和最大內存使用量:dom

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


用virsh命令調整cpu的數量(cpu顆數,已經上線主機只增不減)ide

如今主機狀態:ui

# 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
  
# ps -C qemu-kvm -o rss,cmd
  RSS CMD
388736 /usr/libexec/qemu-kvm -name bbotte -S -M rhel6.6.0 -enable-kvm -m 1024 -realtime mlock


調整cpu數量:
spa

virsh setvcpus [domain-name, domain-id or domain-uuid] [count]3d

減小核數:blog

[root@localhost ~]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     bbotte                         running

內存

[root@localhost ~]# virsh setvcpus bbotte 2  #原來4顆cpu,如今爲2顆,下圖爲guest主機get

wKioL1UzW1vQ_mLZAAJZU18ahxk506.jpg

  
wKioL1UzW6XCV06DAAHaGCct5TA384.jpg

從2顆cpu增至4顆cmd

# virsh setvcpus bbotte 4

guest主機裏面:

# CPU 2 got hotplugged
Booting Node 0 Processor 2 APIC 0x2
CPU 3 got hotplugged
kvm-clock: cpu 2, msr 0:23167c1, secondary cpu clock
Disabled fast string operations
kvm-stealtime: cpu 2, msr 230e880
Will online and init hotplugged CPU: 2
Booting Node 0 Processor 3 APIC 0x3
kvm-clock: cpu 3, msr 0:23967c1, secondary cpu clock
Disabled fast string operations
kvm-stealtime: cpu 3, msr 238e880
Will online and init hotplugged CPU: 3


KVM調整內存使用量:

virsh setmem [domain-id or domain-name]  [count]

如今的內存爲512M,調整爲800M的話:

# virsh setmem bbotte 819200 --config --live

或者# virsh setmem bbotte 800M

# virsh dominfo bbotteId:             2Name:           bbotteUUID:           bd22f444-ee7f-7f00-3d1b-1bb0d0857e43OS Type:        hvmState:          runningCPU(s):         4CPU time:       163.9sMax memory:     1048576 KiBUsed memory:    819200 KiBPersistent:     yesAutostart:      disableManaged save:   noSecurity model: noneSecurity DOI:   0

相關文章
相關標籤/搜索