Skip to content

How to configure unix swap space? advance knowledge article for the new oracle dba




you are a new oracle dba and you would like to know the meaning of the word "swap space" as you have heard recently in some team meeting or when discussing with your unix administrator. It could also be that recently your database was having performance problems and you have heard a senior dba complaning that there is not enough swap space on the server etc. you were wondering what it could be and why not having enough swap space is a problem.

The below article explains about what swap space is and how to configure it and the different ways an operating system could allocate swap space and the factors that one should consider when calculating the swap space requirements. summary is that the server on which your oracle database is present should allocate sufficient swap space otherwise oracle cant start new processes or some processes could crash or there could be performance problems.

now go ahead and enjoy the article.

How to configure swap space [ID 286388.1]  

 
  Modified 09-DEC-2009     Type HOWTO     Status PUBLISHED  
       

In this Document
  Goal
  Solution
  References


Applies to:

Oracle Server – Enterprise Edition – Version: 8.1.7.0 to 11.1.0.6
Information in this document applies to any platform.
***Checked for relevance on 12-09-2009***

Goal

How to configure swap space

Solution

Note: The exact amount of swap space required is dependent on all the applications (not just Oracle) that are run on the machine and the OS being used.
This note outlines basic points one must remember when configuring swap space and is
not intended to provide detailed information on how to configure swap space.

What is "swap space"?
———————————–

Encompassing RAM and the disk space dedicated to it, swap space holds the virtual memory of the system. Every program you run occupies a certain amount of virtual memory. Once all your virtual memory has been allocated to specific applications you cannot start new programs and currently running programs may fail if they try to grow. Physical memory is what you know as the RAM of the system. If you use up all the RAM, your system may run more slowly, but you can still start more programs because the swap space absorbs excess data. The physical memory contains the current "working set" of virtual memory — this means the parts of your applications that are actually running on the CPU. The other parts — "passive parts" of the application are kept on the swap area.

The major factor that is to be considered when configuring swap is "The total
virtual memory required by all applications" on the machine.

The old formulae used are, ( takes physical ram alone into consideration)
+ Minimum of 400Mb or 2* size of RAM which ever is greater.
OR
+ If physical RAM < 2GB , swap = 2* Physical RAM
If Physical RAM >2B & <4GB swap = Size of Physical RAM
If Physical RAM > 4GB swap = 4GB

The above formulae can be used as a starting point. A more presice way
of estimating swap would require, understanding memory requirements of the applications and OS configuration.

This note gives the general overview of swapping mechanism in different OS and
the virtual memory of Oracle.

Different models in swap allocation
——————————————————

There are two allocation strategies used for swapping.
1. Eager allocation model
2. Lazy allocation model.
(Sometimes lazy is referred to as over commitment mode)

+Eager preallocates space in the swap area at process creation time.
+Lazy allocates it on demand (when the process must be paged out).
+Eager has the advantage that it is harder to have random processes killed
because of lack of swap space since it preallocates space.
+It has the disadvantage of permitting far fewer processes to run on the machine.

Also, in some operating systems (like Solaris) if the RAM is huge, the swap space is not necessarily allocated on the disk. A part of physical RAM would be reserved for swapping.
In that case, we dont need huge disk swap.

To know the swap allocation model do contact the OS vendor.
Here is generic information on platforms like Solaris/HP/TRU64

Solaris: Unless you have very huge RAM, follows eager swap algorithm.
( allocation model is program dependent)

HP: Lazy Allocation Model is available only from 11.X.

Tru64: If the file /sbin/swapdefault exists, eager model is being used. Else
lazy model is used.

What factors are to be considered to configure swap space
————————————————————————————
+ The total virtual memory of the processes running on the machine
+ The allocation model used by OS
+ Other OS overheads

Roughly in a eager model,
Minimum swap required = Total virtual memory of all the processes on the Machine

In a lazy model,
Minimum swap required = Total virtual memory of all processes – Physical memory (RAM)

Virtual memory required by Oracle = Size of SGA + Sum of private memory of all server processes.

The private memory can be calculated as
select sum(value )
from v$sesstat s , v$statname n
where s.statistic# = n.statistic#
and n.name like ‘%ga memory’;

Run the query at the peak time.

Commands to configure swap
———————————————-

1, Swap space usage
Sunos: pstat -T
Solaris: swap -l
HP: swapinfo -m (9.X) swapinfo -m

2. Adding Raw Swap partition
After identifying the right device,
SunOs: swapon /dev/sd3b
Solaris: swap -a /dev/dsk/c0t1d0s1
HP: swapon -e -p 1 /dev/dsk/c201d2s0

3.Adding File System Swap
SunOS: mkfile -v 20m /usr/swapfile
Solaris: mkfile 20m /opt/swapfile
HP: /etc/swapon -l 5000 -r 10000 -p 2 /swap

4.The 11g install guide gives this formula for swap:

If RAM = 1024MB to 2048Mb
then 1.5 times RAM
elseif RAM > 2048MB and < 8192MB
then match RAM
else RAM > 8192MB
then .75 times RAM

References:
——————-
Clearing up swap space confusion
http://www.sun.com/sun-on-net/itworld/UIR980701perf.html
System Administration Guide HP
System Adminstration Guide Tru64.

References

NOTE:169706.1 – Oracle� Database on Unix AIX�,HP-UX�,Linux�,Mac OS� X,Solaris�,Tru64 Unix� Operating Systems Installation and Configuration Requirements Quick Reference (8.0.5 to 11.2)

Related


Products


  • Oracle Database Products > Oracle Database > Oracle Database > Oracle Server – Enterprise Edition

Keywords


SWAP SPACE

 

Back to top

Rate this document 

Article Rating

Rate this document
Excellent
Good
Poor
 
Did this document help you?
Yes
No
Just browsing
 
How easy was it to find this document?
Very easy
Somewhat easy
Not easy

 

  Comments

 
Cancel    

 

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Post a Comment

You must be logged in to post a comment.