感谢支持
我们一直在努力

KVM libvirt的CPU热添加

1、CentOS7.3:
需求:说明:默认有两个cpu,由于压力较大的情况下,需要在线添加一个1个cpu

添加cpu前,查看cpu信息

[root@localhost ~]# cat /proc/cpuinfo 
processor: 0
vendor_id: GenuineIntel
cpu family: 6
model: 58
model name: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
stepping: 9
microcode: 0x1
cpu MHz: 2494.342
cache size: 4096 KB
physical id: 0
siblings: 1
core id: 0
cpu cores: 1
apicid: 0
initial apicid: 0
fpu: yes
fpu_exception: yes
cpuid level: 13
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon rep_good nopl pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm fsgsbase tsc_adjust smep
bogomips: 4988.68
clflush size: 64
cache_alignment: 64
address sizes: 42 bits physical, 48 bits virtual
power management:

在线添加cpu信息:

virsh setvcpus CentOS-7.3-X86_64 2 –live    (将cpu的在线个数调整为3个)

添加后进行比对:

[root@localhost ~]# cat /proc/cpuinfo
processor: 0
vendor_id: GenuineIntel
cpu family: 6
model: 58
model name: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
stepping: 9
microcode: 0x1
cpu MHz: 2494.342
cache size: 4096 KB
physical id: 0
siblings: 1
core id: 0
cpu cores: 1
apicid: 0
initial apicid: 0
fpu: yes
fpu_exception: yes
cpuid level: 13
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon rep_good nopl pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm fsgsbase tsc_adjust smep
bogomips: 4988.68
clflush size: 64
cache_alignment: 64
address sizes: 42 bits physical, 48 bits virtual
power management:
processor: 1
vendor_id: GenuineIntel
cpu family: 6
model: 58
model name: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
stepping: 9
microcode: 0x1
cpu MHz: 2494.342
cache size: 4096 KB
physical id: 1
siblings: 1
core id: 0
cpu cores: 1
apicid: 1
initial apicid: 1
fpu: yes
fpu_exception: yes
cpuid level: 13
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon rep_good nopl pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm fsgsbase tsc_adjust smep
bogomips: 4988.68
clflush size: 64
cache_alignment: 64
address sizes: 42 bits physical, 48 bits virtual
power management:
[root@localhost ~]# cat /proc/interrupts 
          CPU0      CPU1       
  0:        679          0  IO-APIC-edge      timer
  1:        10          0  IO-APIC-edge      i8042
  6:          3          0  IO-APIC-edge      floppy
  8:          0          0  IO-APIC-edge      rtc0
  9:          1          0  IO-APIC-fasteoi  acpi
 10:        28          0  IO-APIC-fasteoi  ehci_hcd:usb1, uhci_hcd:usb2
 11:      2930          0  IO-APIC-fasteoi  uhci_hcd:usb3, uhci_hcd:usb4, virtio3
 12:        15          0  IO-APIC-edge      i8042
 14:      3348          0  IO-APIC-edge      ata_piix
 15:          0          0  IO-APIC-edge      ata_piix
 24:          0          0  PCI-MSI-edge      virtio0-config
 25:      1707          0  PCI-MSI-edge      virtio0-input.0
 26:          1          0  PCI-MSI-edge      virtio0-output.0
 27:          0          0  PCI-MSI-edge      virtio2-config
 28:      5807          0  PCI-MSI-edge      virtio2-req.0
 29:          0          0  PCI-MSI-edge      virtio1-config
 30:          3          0  PCI-MSI-edge      virtio1-virtqueues
NMI:          0          0  Non-maskable interrupts
LOC:      74004        208  Local timer interrupts
SPU:          0          0  Spurious interrupts
PMI:          0          0  Performance monitoring interrupts
IWI:      5362          6  IRQ work interrupts
RTR:          0          0  APIC ICR read retries
RES:        20        61  Rescheduling interrupts
CAL:          0        89  Function call interrupts
TLB:          0          3  TLB shootdowns
TRM:          0          0  Thermal event interrupts
THR:          0          0  Threshold APIC interrupts
DFR:          0          0  Deferred Error APIC interrupts
MCE:          0          0  Machine check exceptions
MCP:        12          1  Machine check polls
ERR:          0
MIS:          0
PIN:          0          0  Posted-interrupt notification event
PIW:          0          0  Posted-interrupt wakeup event

2、Win2012:

setvcpus win2012 2 –live
不需要进行激活操作,系统会自动识别新的CPU

3、注意事项

a、KVM虚拟化不能在线减少CPU,cpu热添加技术适合不能停机但是cpu性能严重不足的场景
b、CPU热添加的技术对宿主机以及虚拟机操作系统版本要求较高
c、CPU热添加,总数不能大于最大CPU个数
 <vcpu placement=’auto’ current=‘1’>4</vcpu>

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-05/144229.htm

赞(0) 打赏
转载请注明出处:服务器评测 » KVM libvirt的CPU热添加
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏