This document discusses optimizing Oracle databases that run on VMware virtual machines. It covers VMware's memory, CPU, and I/O resource management and provides recommendations for configuration. Key points include using memory reservations to avoid swapping, allocating enough vCPUs while avoiding overprovisioning, dedicating storage and enabling Storage I/O Control for I/O performance. Oracle RAC support on VMware requires Oracle 11.2.0.2 or higher.
10. Managing ESX memory ESX can “overcommit” memory Sum of all VM physical memory allocations > actual ESX physical memory Memory is critical to Oracle server performance SGA memory to reduce datafile IO PGA memory to reduce sort & hash IO ESX uses four methods to share memory: Memory Page Sharing “Ballooning” Memory compression ESX swapping DBA needs to carefully configure to avoid disaster
11. Configuring VM memory VMs Compete for memory in this range Relative Memory Priority for this VM Maximum memory for the VM (dynamic) Minimum Memory for this VM
13. ESX and VM memory ESX Swap ESX swap VM ESX virtual memory Effective VM physical memory ESX physical memory VM virtual memory
14. ESX Ballooning ESX Swap ESX swap Vmmemctl “balloon” VM ESX virtual memory Apparent VM physical memory Effective VM physical memory ESX physical memory VM Swap VM Swap
15. ESX Ballooning As memory grows, ESX balloon driver (vmmemctl) forces VM to page out memory to VM swapfile
16. ESX Ballooning Inside the VM, paging to the swapfile is observed. The guest OS will determine which pages are paged out If LOCK_SGA=TRUE, then the SGA should not be paged.
17. ESX Swapping ESX Swap ESX swap ESX virtual memory VM Effective VM physical memory ESX physical memory VM virtual memory
18. ESX Swapping ESX Swap ESX swap VM Apparent VM physical memory Effective VM physical memory ESX virtual memory ESX physical memory
20. ESX Swapping Within the VM, swapping cannot be detected. ESX will determine which memory pages go to disk Particularly occurs when VMware tools are not installed Even if LOCK_SGA=TRUE, SGA memory might be on disk
22. ESX memory management Memory page sharing Multiple VMs can share an identical page of memory (Oracle code pages, etc) Memory compression (new in vSphere 4.1) Pages are compressed and written to cache rather than to disk Swapping is more expensive than ballooning Slower to restore memory OS and Oracle get no choice about what gets paged “Double paging” can occur – guest and ESX both page a block of memory
23. Ballooning vs. Swapping Swingbench workload running on Oracle database – from VMWare whitepaper: http://www.vmware.com/files/pdf/perf-vsphere-memory_management.pdf
24. VMware memory recommendations Paging or swapping of PGA or SGA is almost always a Very Bad Thingtm. Use memory reservations to avoid swapping or ballooning Install VMware tools to allow ballooning instead of swapping Set Memory reservation = PGA+SGA+process Overhead Be realistic about memory requirements: In physical machines, we are used to using all available memory In VM, use only the memory you need, freeing up memory for other VMs Oracle advisories (or Spotlight) can show you how much memory is needed Reduce VM reservation and Oracle memory targets in tandem to release memory
27. ESX CPU management If more virtual CPUs than ESX CPUs, then vCPUs will sometimes wait for physical CPU Time “stops” inside the VM when this occurs For multi-CPU VMs, it’s (nearly) all or nothing. A vCPU can be in one of three states: Associated with an ESX CPU but idle Associated with an ESX CPU and executing instructions Waiting for ESX CPU to become available Shares and reservations determine which VM wins access to the ESX CPUs
28. Configuring VM CPU VMs compete for CPU in this range Shares determine relative CPU allocated when competing
29. CPU utilization VM “CPU Ready” is the amount of time VM spends waiting on ESX for CPU Inside the VM, CPU stats can be misleading
30. SMP for vCPUs ESX usually has to schedule all vCPUs for a VM simultaneously The more CPUs the harder this is Some CPU is also needed for ESX More is therefore not always better (Thanks to Carl Bradshaw for letting me reprint this diagram from his Oracle on VMWare whitepaper)
31. ESX CPU performance comparisons VT enabled Vs 2 core 1.8 GHz physical machine
34. ESX CPU recommendations Use up to date chipsets and ESX software Allocate as few VCPUs as possible to each VM Use reservations and shares to prioritise access to ESX CPU Performance of CPU critical workloads may be disappointing on older hardware Monitor ESX Ready time to determine the “penalty” of competing with other virtual machines
37. IO Resource Allocation Disk shares can be used to prioritize IO bandwidth. This is poorly implemented prior to vSphere 4.1
38. Storage IO Control Prior to vSphere 4.1: disk shares could be used only at the VM level, and only within a single ESX host vSphere 4.1 Storage IO Control (SIOC): Manages disk share priorities for all VMs attaching to the same datastore Is triggered by high (“congested”) latency Can be enabled globally at the datastore level Enables equitable distribution even when set to defaults
43. Optimal configuration See “Oracle Database Scalability in VMware® ESX” at www.vmware.com/oracle Each virtual disk directly mapped via RDM to dedicated RAID 0 (+1) group 41 Spindles!
44. ESX IO recommendations Follow normal best practice for physical disks Avoid sharing disk workloads Dedicated datastores using VMFS Align virtual disks to physical disks? Consider Raw Device Mapping (RDM) Consider SIOC in vSphere 4.1 If you can’t optimize IO, avoid IO: Tune, tune, tune SQL Prefer indexed paths Memory configuration Don’t forget about temp IO (sorts, hash joins)
50. Paravirtualizationvs “Hardware Virtualization” Virtualization is not emulation.... Where-ever possible, Hypervisor runs native code from OS against underlying hardware Because a virtualized operating system is running outside privileged x86 “ring 0”, direct calls to hardware need special handling. The three main approaches are: Full Virtualization (VMWare on older hardware) ParaVirtualization (Xen, Oracle VM) Hardware Assisted Virtualization (Intel VT, AMD-V)
51. Full virtualization Hardware calls from the VM are handled by the hypervisor by: Catching the calls as they occur at run time Re-writing the VM image at load time (binary translation) Requires no special hardware Supports any guest OS Relatively Poor performance Used by ESX on older chip-sets VM Hypervisor Ring 0 Hardware
52. Hardware Assisted virtualization Intel VT and AMD-V chips add a “root mode”. VMcan issue instructions from non-root Ring 0. CPU can divert these to hypervisor No changes to OS required Good performance Requires modern chipsets Root Mode Non-Root Mode VM Hypervisor Ring 0 Hardware
58. Paravirtualization, ESX and RAC Prior to 11.2.0.2, Oracle relied on paravirtualized kernels to maintain time synchronization for RAC clusters. From 11.2.0.2 Oracle uses Cluster Time Synchronization Service (CTSS) to maintain clock sync, and this works on ESX Therefore, Oracle supports RAC on Vmware ESX only from 11.2.0.2 onwards See Oracle MySupport Note 249212.1
59. References Latest version of this presentation: http://www.slideshare.net/gharriso/optimize-oracle-on-vmware-5271530 My blog (www.guyharrison.net ): http://guyharrison.squarespace.com/blog/2010/2/22/memory-management-for-oracle-databases-on-vmware-esx.html http://guyharrison.squarespace.com/blog/2010/4/9/esx-cpu-optimization-for-oracle-databases.html http://guyharrison.squarespace.com/blog/2010/7/12/stolen-cpu-on-xen-based-virtual-machines.html http://www.vmware.com/files/pdf/perf-vsphere-memory_management.pdf http://www.vmware.com/files/pdf/Oracle_Databases_on_vSphere_Deployment_Tips.pdf http://www.vmware.com/files/pdf/techpaper/VMW-vSphere41-SIOC.pdf
Notes de l'éditeur
Apologies, I’m a database type.....Quest is best known for toad, but we also have enterprise monitoring across all levels of the stackIn Melbourne, SQL Navigator + the spotlights. It’s not a complete co-incidence about the star trek theme.
As well as total memory to the VM, you can:Adjust memory “shares”, which determine priority for this machine when in contention with other machinesReservation: guaranteed (sort of) amount of memory to allocate Limit, if you want to prevent VM from getting all it’s memory Memory reservationsMemory SharesIdle memory taxMemory sharingThe Balloon driver (vmmemctl) ESX swapping