KVM libvirt的CPU热添加

1、CentOS7.3:

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

添加cpu前,查看cpu信息

[[email protected] ~]# 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个)

添加后进行比对:

[[email protected] ~]# 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:
[[email protected] ~]# 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>

时间: 2024-08-02 01:29:21

KVM libvirt的CPU热添加的相关文章

kvm系列之四:热添加技术

kvm虚拟机可以在线添加cpu.磁盘.内存.网卡等资源,也可以在线迁移虚拟机,这边博文记录这些技术的实现方法.有两点需要注意: 这里主要操作是在web01虚拟机中进行,为了方便,我将它的网卡改成了桥接模式 根分区的扩容时需要关机的 热添加磁盘 为虚拟机添加一块磁盘的流程: 宿主机创建磁盘 宿主机将磁盘附加给虚拟机 虚拟机中格式化磁盘 虚拟机中挂载并使用磁盘 操作过程记录如下: 虚拟机磁盘初始状态 [[email protected] ~]# fdisk -l Disk /dev/vda: 10.

kvm热添加磁盘,并为根目录扩容,重启依然生效

接上篇,<<热添加磁盘,重启文件不丢失>> 一.理论扫盲:centos7的磁盘默认使用lvm,所以是可以直接扩展根分区的,但是无法缩小,在物理机中会默认将磁盘分为两个分区,分别为sda1和sda2,其中分区sda1作为系统盘/boot挂载,少量空间:sda2作为一个物理卷并且完全作为逻辑卷组VG(Volume Group)centos,在这个逻辑卷组centos中建立三个逻辑卷LV(Logical Volume)root和home还有swap,分别挂载到根目录/和/home以及sw

QEMU KVM Libvirt手册(7): 硬件虚拟化

在openstack中,如果我们启动一个虚拟机,我们会看到非常复杂的参数 qemu-system-x86_64 -enable-kvm -name instance-00000024 -S -machine pc-i440fx-trusty,accel=kvm,usb=off -cpu SandyBridge,+erms,+smep,+fsgsbase,+pdpe1gb,+rdrand,+f16c,+osxsave,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+v

QEMU KVM Libvirt手册(10):Managing Virtual Machines with libvirt

libvirt is a library that provides a common API for managing popular virtualization solutions, among them KVM and Xen. 使用virt-install创建image qemu-img create -f qcow2 /tmp/centos5.8.img 10G virt-install --virt-type qemu --name centos-5.8 --ram 2048 --

vSphere 5.0热添加

vSphere环境支持通过vCenter热添加硬件的功能,之前比较多的用的是添加硬盘和网卡,最近因为比较多的情况需要在线添加内存和CPU.之前曾经尝试过几次,因为每次添加完成之后都没有办法识别到增加的部分,今天刚好在网上找资料的时候看到了相关内容,自己尝试了一下,结果很有效,把过程记录下来. 首先需要通过vCenter开启热插拔的功能. 需要注意的是,开启该功能需要在关机的情况下启用. 之后打开虚拟机之后看到虚拟机的内存为4G. 接下来修改内存的大小,将内存大小改为6G. 登陆系统中查看,内存大

QEMU KVM libvirt 手册(1)

安装 对虚拟化的支持通常在BIOS中是禁掉的,必须开启才可以. 对于Intel CPU,我们可以通过下面的命令查看是否支持虚拟化. # grep "vmx" /proc/cpuinfo flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdp

QEMU KVM libvirt手册(2)

Administrating Virtual Machines with QEMU Monitor When QEMU is running, a monitor console is provided for performing interaction with the user. Using the commands available in the monitor console, it is possible to inspect the running operating syste

QEMU KVM libvirt手册(4) &ndash; images

RAW raw是默认的格式,格式简单,容易转换为其他的格式.需要文件系统的支持才能支持sparse file 创建image # qemu-img create -f raw flat.img 10GFormatting 'flat.img', fmt=raw size=10737418240 如果我们ls则看到 ls -lh flat.img -rw-r--r-- 1 root root 10G Jun 30 22:27 flat.img 但是并不真正占用10G # du -h flat.im

QEMU KVM Libvirt手册(10): KVM的各种限制

Overcommits KVM allows for both memory and disk space overcommit. However, hard errors resulting from exceeding available resources will result in guest failures. CPU overcommit is also supported but carries performance implications. Time Synchroniza