Performance Tuning Oracle Rac On Linux
Performance Tuning Oracle Rac On Linux
Performance Tuning Oracle Rac On Linux
www.perftuning.com
INTRODUCTION
Performance tuning is an integral part of the maintenance and administration of the Oracle database server. Performance
tuning includes modifications to the application and SQL statements, index creation and maintenance, and Oracle instance
tuning. The tuning process and the areas optimized are the same regardless of the operating system, and therefore, will not be
covered in detail in this paper. Instead, this paper will focus on the aspects of performance tuning that apply to the Linux
operating system. In addition, storage sizing will also be covered here.
Performance tuning is as much an art as it is a skill. It involves patience, the ability to think outside the box, and a positive
attitude. With each version of Oracle, the monitoring and troubleshooting tools improve. In addition, Oracle now provides
more tools to monitor the OS as well. These include Grid Control, Lightweight Onboard Monitor (LTOM) and the Oracle
OS Watcher (OSW). This paper will also explore these tools and how to best apply them.
HARDWARE TUNING
Several important tasks where performance tuning considerations must be taken into account include; hardware sizing, capacity
planning and hardware design and configuration. All of these tasks involve some type or level of hardware tuning. When
initially designing and configuring the system that will be hosting the Oracle database server, it is important to keep
performance in mind. Too often price is the only consideration and performance is an afterthought. Some tuning problems
can be resolved after the fact, but capacity issues are more difficult to address and might involve the addition or change of
hardware or other resources.
In order to choose the right hardware, one must determine the following:
• How much physical memory do you need? The amount of memory will determine how well you are able to cache
objects and run large queries. Keep in mind the memory that might be needed for multiple Oracle caches as well as
non-standard block size caches.
• What type and how many CPUs/Cores are required to support the expected system load?1
• What type of application(s) will be run?
• How much CPU power is needed?
• Will the servers be configured as a Real Application Cluster (RAC)? If so, how many nodes should there be? What
type and speed are the networking components that will be used as the cluster interconnect?
• Is storage sized properly?
Answers to these questions and others will help you decide how to configure the system.
1 Oracle is currently licensing a core as ½ of a CPU, thus 2 cores require a 1 CPU license.
1
• Limited to 4 GB of virtual memory per process. This limitation is not usually problematic in Linux, but should be
avoided nevertheless.
• Low memory issues. With 32-bit Linux there is special low memory below 840 MB reserved for kernel operations,
page table entries and DMA. This memory can be taxed at times, thus causing process failures.
• Physical memory limitations. With the best 32-bit hardware, physical memory is limited to 64 GB. This is built into
the architecture and cannot be extended.
These issues can easily be avoided by running 64-bit Linux and 64-bit Oracle software.
If a disk drive takes 7 ms to do a typical random I/O, then you can do approximately 142 random I/Os per second as the
theoretical maximum. However, because of queuing and collisions, as you near that theoretical maximum, the 7 ms I/O
latency begins to increase exponentially. As you surpass 142 I/Os per second, queuing occurs and the I/O latency or response
time is equal to:
As the number of items in the queue increases, the length of the queue increases exponentially as shown in the following
graph:
2
www.perftuning.com
As the queue length increases, so does the response time. In a poorly sized I/O subsystem it is not uncommon to see latencies
in the 100’s of milliseconds. This can be avoided somewhat by properly sizing the I/O subsystem. The problem may also be
reduced by properly tuning queries in order to reduce unnecessary I/Os.
There are a number of I/O subsystems available on the market today. Typically we find larger databases either using SAN or
NAS subsystems. In the past, IT Managers avoided NAS to store data, but improvements in the technology make these
subsystems faster and more reliable and an ideal choice for Oracle databases. For example, with Oracle 11g, an NFS client is
built into the Oracle database server itself, thus reducing NAS overhead further.
SAN
The Storage Area Network or SAN has been the most common I/O subsystem for large Oracle databases. The SAN is an
actual network of computer systems, fibre channel switches and storage subsystems. These systems form a network where
multiple systems can access one or more storage subsystems, which can easily be shared, thus providing shared storage for
RAC clusters. In addition, SAN storage systems typically support a large amount of cache and performance features.
However, no matter what features and cache is available, the fundamental building block of the storage subsystem is still the
disk drive.
NAS
In the past, Network Attached Storage or NAS systems typically did not provide enough performance for the Oracle database
server, however, with gigabit and faster networks, TCP Offload Engine (TOE) adapters and faster network gear, NAS is now a
viable option for the Oracle database server. One reason that NAS has become more popular is that it tends to be less
expensive than SAN because it uses the existing network infrastructure.
NAS performance can be enhanced via the use of TOE network adapters and by optimally configuring the NAS device in
/etc/fstab. Here is an example of a NAS device:
Note: For file systems that only contain Oracle data files (not Oracle program files) you can use forcedirectio as well.
For RAC systems, include the parameter noac.2
By properly configuring the NAS device, performance can be enhanced. With NFS it is particularly important to use the
proper mount parameters. In addition, if possible, use a dedicated network for storage processing.
RAID
Both SAN and NAS systems support a number of RAID levels. Like most configurable components, there are tradeoffs.
Some RAID levels are slower and more economical, while other RAID levels are faster and more expensive. For most SAN
and NAS systems it is recommended that RAID 10 be used rather than RAID 5. RAID 5 is more economical, but the write
performance is slower than RAID 10. In addition, if the RAID volume is in a degraded state (i.e. a drive has failed) RAID 5
has a much higher rebuild penalty and performance is greatly degraded.
• An Oracle RAC interconnect, where the RAC interconnect experiences extensive traffic and most packets are large.
• Networks dedicated for storage, where NAS is used via a private network.
• Networks dedicated for backup, where a dedicated network is used for backups.
Jumbo frames should not be used on your general public network, because it can degrade performance for small Oracle net
packets.
VLANS
The Virtual Local Area Network (VLAN) is a private network carved out of your network infrastructure. In a VLAN, only the
traffic destined for systems within the VLAN is permitted, thus general network broadcasts are blocked out. A VLAN can be
effective for a RAC interconnect a private backup network, or a private storage network. Each individual system’s purpose
and requirements must be taken into account to determine whether a VLAN will be effective.
OS TUNING
There are a number of areas that can be tuned in the Operating System (OS), however, not all of them will directly provide
better performance. For example, allocating more shared memory in the OS does not in itself provide greater performance.
However, by allocating more OS shared memory; a larger SGA can be created by Oracle, which will potentially provide greater
performance.
4
www.perftuning.com
This output shows Oracle allocating two shared memory segments. The 129 MB segment is used by the ASM instance, the
920 MB shared memory segment is used by the Oracle database instance. The information under nattch shows how many
processes are connected to the shared memory segment.
NETWORK TUNING
Linux networking parameters can be tuned, thus improving the performance of the Oracle RAC interconnect. This will
provide significant improvement in RAC operations. There are several parameters that should be tuned in the Linux system
for Oracle 10g. Below are the recommended OS maximum send and receive buffer sizes for Oracle 10g. These settings should
be set in the /etc/sysctl.conf file by adding the following lines to increase the default and max receive read and write buffer
sizes:
These parameters tell Linux how much buffer space to reserve for each socket.
Note: For Oracle 9i, the recommendation is for both rmem and wmem to be set to 256K.
Note: For Oracle 11g, the recommendation is to set both rmem and wmem to 4194304.
The amount of traffic being sent across the network can be monitored by using the Linux command sar. Using the command
sar –n DEV the number of packets and throughput can be seen as shown here:
By monitoring the networks you can determine if the interconnect is being overutilized. Some interconnect statistics are
available in the Oracle AWR reports as well.
HUGEPAGES
When using large amounts of memory for Oracle, the OS consumes significant resources to manage the pagetable. The
pagetable is a table that keeps track of the virtual memory used by all of the processes in the system. The pagetable has a cache
called the TLB (Translation Lookaside Buffers). The TLB speeds up lookups by caching the pagetable entries, just like any
other cache. Unfortunately, the TLB is fairly small and will hold on the order of 512 to 4096 entries.
When using 64-bit Linux and lots of memory (above 8GB), the number of pagetable entries (and the associated memory) can
be very large. The following example of meminfo output for a large SGA shows the TLB pagetable entries taking up 766 MB
of RAM.
5
www.perftuning.com
This can be a significant overhead on the system. By enabling hugepages (by setting a Linux parameter) or large page
allocations for database buffers, the number of TLB entries can be reduced by increasing the page size. In Linux, when
hugepages are used, the page size is changed from the default of 4 KB to 2 MB. In the Linux 2.6 kernel, hugepages are
configured by setting the Linux initialization parameter vm.nr_hugepages to the number of 2M pages that you want. This
reduces the total number of pages by making each page larger.3
Note: Hugepages are only used for the Oracle SGA. The OS will run with a combination of 4 KB and 2 MB pages when
hugepages is enabled.
TUNING IO
There are only a few things that you can actually do from the OS perspective to tune the I/O subsystem. One is to change
parameters in the device driver, which is not recommended. The other is to change the I/O scheduler. The Linux operating
system has replaced the elevator sorting algorithms (tuned with elvtune) in the 2.4 kernel with multiple I/O schedulers.
I/O SCHEDULERS
The Linux 2.6 kernel provides four I/O schedulers to choose from, each with its own characteristics and designed to perform
optimally for different types of environments, as described in the following sections. The I/O scheduler is specified in the
/boot/grub/grub.conf configuration file, at the end of the kernel selection line, by adding the following:
The cfq scheduler is the default scheduler for Linux and is usually the best general purpose scheduler. This scheduler
maintains a per-process I/O queue. It attempts to distribute available bandwidth equally among all I/O requests. It is well
suited for multi-processor systems and for storage subsystems with multiple LUNs and controllers. This is the default
scheduler because it seems to perform well among a number of diverse workloads.
The deadline scheduler uses a deadline algorithm to minimize latency. It is said to provide near real-time behavior by using a
round robin policy. In addition it will aggressively re-order requests. There is some speculation that this might be a better
scheduler under a heavy Oracle workload.
The noop or no op scheduler is a simple FIFO queue. It uses minimal CPU and assumes I/O will be optimized by the HBA
or external disk controller. In theory, this should be an ideal scheduler for high powered SAN systems, since the idea of the
noop scheduler is to simply get the request down to the I/O subsystem as quickly as possible. No processing or re-ordering is
done on the I/O request.
THE AS SCHEDULER
The as or anticipatory elevator scheduler is similar to what was done in the 2.4 kernel. It uses controlled delay to allow time
for requests to be re-ordered by elevator algorithms. This scheduler is designed for small or slow disk subsystems. It works by
delaying the I/O and then re-ordering the I/Os in the queue. Since the underlying storage is probably a RAID array, the
requests will have to be re-ordered on a per-disk basis later anyway. This scheduler should not be used with database systems.
MONITORING I/O
Since the I/O subsystem performance is extremely important to the overall performance of Oracle, it should be closely
monitored. Monitoring the I/O subsystem can be done via the iostat command. By running iostat –x it is possible to get more
detailed information on the performance of the I/O subsystem, such as service time (svctm) and average wait time (await). The
output from this command appears as follows:
7
www.perftuning.com
ORACLE TUNING
Tuning Oracle on Linux is no different than tuning Oracle on other platforms. The basic goals of tuning are still in place;
reduce the amount of resources being used to process SQL statements, optimize the use of CPU and memory, and attempt to
reduce the time spent blocking on other processes.
In a RAC environment reducing interconnect traffic is an essential part of tuning the system. The RAC interconnect can be
the limiting component to scalability. Since the typical interconnect hardware is gigabit Ethernet, there is not much that can be
done to the physical hardware with the exception of the network tuning recommended earlier in this paper. However,
interconnect traffic can be reduced via programming techniques and architecture. Services can be used to isolate specific
functions to be performed on specific nodes in an effort to eliminate the occurrence of updates to the same tables and same
rows on different nodes, thus reducing the amount of data blocks being bounced around the network, which should be
avoided as much as possible.
8
www.perftuning.com
ONGOING MONITORING
Ongoing monitoring is an important part of performance tuning. There are a number of tools available for ongoing
monitoring including Oracle AWR reports, Grid Control, LTOM, OSW as well as numerous third party tools. Which
monitoring tool you use is important, however, what’s more important, is that something be used. If you do not regularly
monitor the system, you may only find out about performance problems from the user community. By that time it is often too
late. Proactive tuning is much better in the long run than tuning only when a problem is reported.
GRID CONTROL
Grid Control provides an excellent method of both alerting and monitoring. It provides excellent OS monitoring capabilities,
as shown in this figure, including agents for specific operating systems such as Linux and Linux x86_64. These agents provide
both the ability to monitor the OS as shown below, and the ability to monitor the Oracle instances on the system.
Take specific care to monitor the disk latencies. A typical average I/O latency should not exceed 20 ms. If you are seeing
much higher latencies, they should be investigated.
9
www.perftuning.com
OSW AND LTOM
Oracle has recently begun offering a set of lightweight tools that can be used to monitor the system. The OS Watcher (OSW)
tool is a collection of UNIX shell scripts intended to collect and archive OS and network metrics to aid in diagnosing
performance issues. OSW operates as a set of background processes on the server and gathers OS data on a regular basis,
invoking such Linux utilities as vmstat, netstat, and iostat. The tool is installed on each node where data is to be collected.
OSW can be set up to automatically monitor the system during specified times and the data it collects can be turned into
graphs that are created in the GIF format as shown here:
The Oracle Light Onboard Monitor (LTOM) is another tool that is used for monitoring both the Oracle instance and the OS.
It is a java program that is designed as a real-time diagnostic platform. LTOM provides some of the same data that is available
with OSW, but provides Oracle session and wait event information as well. LTOM is tightly integrated with the host OS and provides an
integrated solution for detecting and collecting trace files for system performance issues. LTOM is designed to be
a proactive, rather than a reactive monitoring tool. LTOM delivers automatic problem detection and collects the necessary
diagnostic information while the performance problem is occurring. It provides services for:
Detailed information on the LTOM utility can also be downloaded from Oracle Metalink, along with the appropriate User
Guide information.5.
SUMMARY
Performance tuning is an integral part of the maintenance and administration of the Oracle database server. It involves
patience, perseverance, and the ability to think outside of the box. It is as much an art as it is a skill. It takes constant
monitoring and tuning in order to keep the Oracle database running optimally. With each version of Oracle, the monitoring
and troubleshooting tools constantly improving. In addition, Oracle is now providing more tools to monitor the OS as well.
This includes Grid Control, Lightweight Onboard Monitor (LTOM) and the Oracle OS Watcher (OSW). It is great to have
these tools to help, but it still takes manual labor in order to keep things running smoothly and optimally.
This paper covered a number of aspects of performance tuning Oracle on Linux and some tips on what to look for and
parameters to set. Do not consider this paper to be the final word in performance tuning Oracle on Linux. There will always
be changes and new challenges to overcome.