Enable CPU-Hot Plug and RAM-Hot Add at Virtual machines on VMware vCenter 5
Update 12.02.2013 / Gabrie post in the comments a important extra info about Hot-Add and post the link to the blog from Duncan Epping: http://www.yellow-bricks.com/2012/01/16/enabling-hot-add-by-default-cc-gabvirtualworld/ it’s important to read this!!!
vSphere Virtual Machine Administration, Chapter 8 “Configuring Virtual Machines”, Section “Change CPU Hot Plug Settings in the … Client”, page 94.
Some conditions and requirements for CPU Hot Plug
- If possible, use hardware version 8 virtual machines.
- Hot-adding multicore virtual CPUs is supported only with hardware version 8 virtual machines.
- Not all guest operating systems support CPU hot add.
- To use the CPU hot-add feature with hardware version 7 virtual machines, set the Number of cores per socket to 1.
- Adding CPU resources to a running virtual machine with CPU hot plug enabled disconnects and reconnects all USB passthrough devices connected to that virtual machine.
- For Linux guest operating VMware Tools must be installed.
- The virtual machine must powered off to configure he Hot CPU settings.
- Hot remove of Memory is not supported.
- Hot remove of CPU is not supported.
To enable new CPU after adding a new CPU. You can use this script:
Hot add cpu to supported Linux guestOS
#!/bin/bash # William Lam # http://engineering.ucsb.edu/~duonglt/vmware/ # hot-add cpu to LINUX system using vSphere ESX(i) 4.0 # 08/09/2009 for CPU in $(ls /sys/devices/system/cpu/ | grep cpu | grep -v idle) do CPU_DIR="/sys/devices/system/cpu/${CPU}" echo "Found cpu: "${CPU_DIR}" ..." CPU_STATE_FILE="${CPU_DIR}/online" if [ -f "${CPU_STATE_FILE}" ]; then STATE=$(cat "${CPU_STATE_FILE}" | grep 1) if [ "${STATE}" == "1" ]; then echo -e "t${CPU} already online" else echo -e "t${CPU} is new cpu, onlining cpu ..." echo 1 > "${CPU_STATE_FILE}" fi else echo -e "t${CPU} already configured prior to hot-add" fi done
Hot adding memory in Linux
ONLY for Suse Linux Enterprise Linux 11
Note: These instructions work for SLES OS. Other distributions may be different.
To enable acpi_memhotplug, run this command within the SLES virtual machine:
modprobe acpi_memhotplug
Using vSphere Client, edit the virtual machine settings to increase the memory assigned to the virtual machine. For more information, see Increasing the amount of memory assigned to a virtual machine (1004059).
Bring the memory online in /sys/devices/system/memory with the command:
echo online > /sys/devices/system/memory/memory[number]/state
Run this command to check the state of the memory, looking for memory that appears offline:
grep line /sys/devices/system/memory/*/state
If memory appears as offline, set it to online with the command:
echo online > /sys/devices/system/memory/memory[number]/state
Verify that you can see the extra memory with the command:
free -m
Expert Mode: PowerCLI
This Works when System is online, but need one “cold” start to enable this function.
Enable-MemHotAdd and Enable-vCpuHotAdd
Function Enable-MemHotAdd($vm){ $vmview = Get-vm $vm | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $extra = New-Object VMware.Vim.optionvalue $extra.Key="mem.hotadd" $extra.Value="true" $vmConfigSpec.extraconfig += $extra $vmview.ReconfigVM($vmConfigSpec) }
Function Enable-vCpuHotAdd($vm){ $vmview = Get-vm $vm | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $extra = New-Object VMware.Vim.optionvalue $extra.Key="vcpu.hotadd" $extra.Value="true" $vmConfigSpec.extraconfig += $extra $vmview.ReconfigVM($vmConfigSpec) }
Good information about hot-add cpu and memory can found here
- http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1015501
- http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1012764
- http://mrpointy.wordpress.com/2010/07/08/vsphere-vm-hot-plug-script/
- http://communities.vmware.com/docs/DOC-10493
- http://paulgrevink.wordpress.com/2012/09/10/vcap5-dca-objective-6-2-troubleshoot-cpu-and-memory-performance/
- http://ict-freak.nl/2009/10/05/powercli-enabledisable-the-vm-hot-add-features/
Important extra info on Hot-Add: http://www.yellow-bricks.com/2012/01/16/enabling-hot-add-by-default-cc-gabvirtualworld/
Thank you Gabrie for this important informations! i have updated my blog post!