63
Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne www.guyharrison.net [email protected] @ guyharrison

Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne [email protected] @guyharrison

Embed Size (px)

Citation preview

Page 1: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Optimize Oracle RDBMS on VMware

Guy HarrisonDirector, R&D Melbournewww.guyharrison.net [email protected]@guyharrison

Page 2: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Introductions

Page 3: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 4: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 5: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 6: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 7: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 8: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 9: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Blue

Yellow

Red

0 10 20 30 40 50 60 70 80

Star trek shirt fatality analysis

Pct

Page 10: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 11: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

11

©2011 Quest Software, Inc. All rights reserved..

Agenda

• Motivations for Virtualization

• VMware ESX resource management:

• Memory

• CPU

• IO

• Paravirtualization (OVM) vs Hardware Assisted

Virtualization (ESX)

• RAC on VMware

Page 12: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

12

©2011 Quest Software, Inc. All rights reserved..

Motivations for Virtualization

• Better utilization of server resources• Reduced power consumption

Server Consolidation

• Fewer physical machines• Backup, cloning, rapid provisioningManageability

• Adjust resources on demand• A complement to the physical “grid”

visionElastic computing

Page 13: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

13

©2011 Quest Software, Inc. All rights reserved..

Resistance to Database virtualization

• Virtual CPU & IO• Sharing of virtual resources Performance

• Large databases too big for a single VM

• RAC-style clustering problematic Scale

• Oracle’s stance often misunderstood

• See MyOracleSupport 249212.1Support

Page 14: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

14

©2011 Quest Software, Inc. All rights reserved..

DB virtualization is happening

Page 15: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

15

©2011 Quest Software, Inc. All rights reserved..

Oracle virtualization is lagging....

SQL Server

File and Print Servers

IIS

Active Directory

Apache

Exchange

Sharepoint

Java

Oracle

None of the Above

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

Which of the following do you run in VMs?

Quest survey of vFoglight users , 2010

Page 16: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

16

©2011 Quest Software, Inc. All rights reserved..

ESX Memory management

Page 17: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

17

©2011 Quest Software, Inc. All rights reserved..

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

• Memory compression

• “Ballooning”

• ESX swapping

• DBA needs to carefully configure to avoid disaster

Page 18: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Configuring VM memory

Relative Memory Priority for this VM

Minimum Memory for this VM

VMs Compete for memory in this range

Maximum memory for the VM (dynamic)

Page 19: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

19

©2011 Quest Software, Inc. All rights reserved..

Monitoring VM memory

Page 20: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Swap

ESX virtual memory

ESX physical memory

VM VM virtual memory

ESX swap

Effective VM physical memory

ESX and VM memory

Page 21: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Swap

ESX virtual memory

ESX physical memory

VM

Apparent VM physical memory

ESX swap

Effective VM physical memory

Vmmemctl

“balloon”

VM SwapVM Swap

ESX Ballooning

Page 22: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Ballooning

As memory grows, ESX balloon driver (vmmemctl) forces VM to page out

memory to VM swapfile

Page 23: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

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.

Page 24: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Swap

ESX virtual memory

ESX physical memory

ESX swap

ESX Swapping

VM virtual memory

VM

Effective VM physical memory

Page 25: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Swap

ESX virtual memory

ESX physical memory

ESX swap

Apparent VM physical memory

VMEffective VM physical memory

ESX Swapping

Page 26: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Swapping

ESX swaps out VM memory to ESX swapfile

Page 27: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

ESX Swapping

• Within the VM, swapping cannot

be detected.

• ESX will determine which

memory pages go to disk

• Usually occurs when VMware

tools are not installed

• Even if LOCK_SGA=TRUE,

SGA memory might be on disk

Page 28: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Avoiding Ballooning and swapping

memory reservations help avoid ballooning or ESX

swapping

Page 29: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

29

©2011 Quest Software, Inc. All rights reserved..

Ballooning vs. Swapping

Swingbench workload running on Oracle database – from VMWare whitepaper: http://www.vmware.com/files/pdf/perf-vsphere-memory_management.pdf

Page 30: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

30

©2011 Quest Software, Inc. All rights reserved..

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

Page 31: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 32: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

32

©2011 Quest Software, Inc. All rights reserved..

ESX CPU management

Page 33: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

33

©2011 Quest Software, Inc. All rights reserved..

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

Page 34: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Configuring VM CPU

VMs compete for CPU in this range

Shares determine relative CPU allocated when competing

Page 35: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

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

Page 36: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

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)

Page 37: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

37

©2011 Quest Software, Inc. All rights reserved..

ESX CPU performance comparisons

Vs 2 core 1.8 GHz physical machine

VT enabled

Page 38: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

38

©2011 Quest Software, Inc. All rights reserved..

Programmatic performance

PLSQL

PLSQL compiled

Java Stored Proc

Simple C program

Standalone Java

0 5 10 15 20 25 30 35 40 45 50

ESX 2 VCPU 2.26 GHz VT enabled

ESX 2 CPU 3.5 GHz no-VT

Physical 2 CPU 1.8 GHz

Elapsed Time (s)

NB: Not a benchmark! Just some informal measurements!!

Page 39: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

39

©2011 Quest Software, Inc. All rights reserved..

Programmatic performance (2)

ESX 2 CPU 3.5 GHz no-VT

ESX 2 VCPU 2.26 GHz VT enabled

0 50 100 150 200 250 300 350

333

72

Elapsed time Pct relative to Physical CPU adjusted for GHz

Page 40: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

40

©2011 Quest Software, Inc. All rights reserved..

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

• Monitor ESX Ready time to determine the “penalty” of competing

with other virtual machines

Page 41: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

41

©2011 Quest Software, Inc. All rights reserved..

ESX IO management

Page 42: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Typical VMWare disk configuration

Page 43: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

IO Resource Allocation

• Disk shares can be used to prioritize IO bandwidth.

• This is poorly implemented prior to vSphere 4.1

Page 44: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

44

©2011 Quest Software, Inc. All rights reserved..

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

Page 45: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Storage IO Control

Page 46: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

46

©2011 Quest Software, Inc. All rights reserved..

vSphere 4.1 SIOC

Page 47: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

47

©2011 Quest Software, Inc. All rights reserved..

SOIC won’t make up for a poorly configured IO layout

Page 48: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Performant VMware disk configuration

Page 49: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

49

©2011 Quest Software, Inc. All rights reserved..

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!

Page 50: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

50

©2011 Quest Software, Inc. All rights reserved..

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)

Page 51: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

51

©2011 Quest Software, Inc. All rights reserved..

Shameless plugs

Page 52: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison
Page 53: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

53

©2011 Quest Software, Inc. All rights reserved..

Page 54: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

54

©2011 Quest Software, Inc. All rights reserved..

Page 55: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

55

©2011 Quest Software, Inc. All rights reserved..

Paravirtualization vs Hardware Virtualization

Page 56: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

56

©2011 Quest Software, Inc. All rights reserved..

Paravirtualization vs “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)

Page 57: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

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

Hardware

Ring 0

Page 58: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Hardware Assisted virtualization

• Intel VT and AMD-V chips

add a non-root mode Ring

0.

• VM can issue instructions

from non-root Ring 0.

• CPU can divert these to

hypervisor

• No changes to OS required

• Good performance

• Requires modern chipsets

Hypervisor

Hardware

VM

Ring 0

Root Mode Non-Root Mode

Page 59: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

Paravirtualization

• VM operating system is rewritten to translate device calls to “hypercalls”

• Hypercalls are handled by a special VM (dom0 in Xen/OVM)

• Good performance but requires modified VM OS

• Xen can use either paravirtualization or hardware assist

Hypervisor

Hardware

VM(domU)

Ring 0VM

(dom0)

Page 60: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

60

©2011 Quest Software, Inc. All rights reserved..

RAC and ESX

Page 61: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

61

©2011 Quest Software, Inc. All rights reserved..

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

Page 62: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

62

©2011 Quest Software, Inc. All rights reserved..

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

Page 63: Optimize Oracle RDBMS on VMware Guy Harrison Director, R&D Melbourne  Guy.harrison@quest.com @guyharrison

COLLABORATE 12April 22-26, 2012

Mandalay Bay Convention CenterLas Vegas, Nevada, USA

www.collaborate12.orgwww.collaborate12.ioug.org