Oracle Database LOCK_SGA Unix OS setting

LOCK_SGA (Real Physical Memory)
##!! My test, The Most People think for Lock SGA in Physical memory but real world not true because OS using concept virtual memory replace physical memory (swap+physical) that Lock SGA->Lock shared memory->Lock in virtual ->(Most real physical memory+a little swap)   


# Refer http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams097.htm#i1128572
Oracle Tips by Burleson Consulting http://www.dba-oracle.com/p_lock_sga.htm

Condition in Oracle
-Disable Automatic Memory Management(AMM)
-Disable Automatic Shared Memory Management (ASMM)
-Enable manual shared memory management

Condition in OS
AIX
1. Aix parameters v_pinshm = 1, default is 0, that will support pin aix live in memory, set the method
# Vmo-p-o v_pinshm = 1
2. Aix memory parameter maxpin% = percentage, default 80%, expressed support for the largest proportion of available pin living memory, set the method
# Vmo-p-o maxpin% = 90
3. Oracle parameters LOCK_SGA = true, that oracle will use this part of the living memory was pin, in fact, to tell oracle to use another kind of memory called method.
HP UNIX
1) Login as root:
2) Create the file "/etc/privgroup":
$vi /etc/privgroup
3) Add line "dba MLOCK" to file.
Note: The group dba is assuming the oracle owner's ID is part of the dba
group.
4) As root, run the command "/etc/setprivgrp -f /etc/privgroup":
$/etc/setprivgrp -f /etc/privgroup
2. Root user, execute the command
# / Etc / setprivgrp-f / etc / privgroup
3. Oracle user, modify the Oracle parameter lock_sga = true
SOLARIS (solaris2.6 more)
8i version of the above database default hidden parameters use_ism = true, automatically lock SGA in memory, do not set lock_sga.
If you set lock_sga = true use of non-root user to start the database will return an error.
WINDOWS
Can not be set lock_sga = true, you can set pre_page_sga = true, makes the database startup took all the memory pages loaded, this may play a role.
Step by Step
show parameter sga_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_target big integer 300M
show parameter lock_sga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
ALTER SYSTEM SET LOCK_SGA=TRUE SCOPE=SPFILE;

Case Can’t Start
startup
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
1) Unlock SGA
ALTER SYSTEM SET LOCK_SGA=FALSE SCOPE=SPFILE;
--or--
2) reduced sga_max_size or sga_target
ALTER SYSTEM SET sga_target=XXXM SCOPE=SPFILE;
3) repeat startup



Fit the SGA into main memory
Because the purpose of the SGA is to store data in memory for fast access, the SGA should be within main memory. If pages of the SGA are swapped to disk, then the data is no longer quickly accessible. On most operating systems, the disadvantage of paging significantly outweighs the advantage of a large SGA.
Note:
The LOCK_SGA parameter can be used to lock the SGA into physical memory and prevent it from being paged out.
Other SGA Initialization Parameters
You can use several initialization parameters to control how the SGA uses memory.
Physical Memory
The LOCK_SGA parameter locks the SGA into physical memory.
SGA Starting Address
The SHARED_MEMORY_ADDRESS and HI_SHARED_MEMORY_ADDRESS parameters specify the SGA's starting address at runtime. These parameters are rarely used. For 64-bit platforms, HI_SHARED_MEMORY_ADDRESS specifies the high order 32 bits of the 64-bit address.
Extended Buffer Cache Mechanism
The USE_INDIRECT_DATA_BUFFERS parameter enables the use of the extended buffer cache mechanism for 32-bit platforms that can support more than 4 GB of physical memory. On platforms that do not support this much physical memory, this parameter is ignored.
Oracle Tips by Burleson Consulting http://www.dba-oracle.com/p_lock_sga.htm
The lock_sga parameter is an operating system dependent (OSD) parm that is used to make the Oracle SGA region ineligible for swapping, effectively pinning the SGA RAM in memory.  This technique is also known as "page fencing", using lock_sga=true to guarantee that SGA RAM is never sent to the swap disk (during a page-out operation.
Because lock_sga is an OSD parm, it will not work on all platforms, and in any case, it's never an ideal solution unless you have no way to add RAM to stop the root cause, the RAM paging.  In Oracle, paging is noted by "page in" operations (as seen in the vmstat "pi" column), but you will get "false" page-ins as the part of normal program starting operations. 
To manage the memory segments, the UNIX and Linux kernel builds a memory map of the entire program when it starts. Included in this map is a note on whether the storage is “in memory” or “on swap disk”. As the program starts it begins accessing some of its pages that have never been loaded into RAM memory. Hence, you may see vmstat page-in’s when a large number of programs are starting and allocating their RAM memory.
See here for details on recognizing "real" server paging. 

When to use lock_sga

In practice, the lock_sga parameter is only needed when you have an over-stressed server with RAM paging, and it's always a better idea to add more RAM than to lock-in the SGA by making it non-swappable.  The lock_sga parameter is also useful in cases with multiple instances on an over-stressed server, where the lock_sga=trueinstance is to have priority over memory usage, at the expense of the other SGA's.
The docs note this about lock_sga (for Oracle AIX Tuning Optimization):
Shared memory can be pinned to prevent paging and to reduce I/O overhead. To perform this, set the LOCK_SGA parameter to true. On AIX 5L, the same parameter activates the large page feature whenever the underlying hardware supports it.
Run the following command to make pinned memory available to Oracle Database:
$ /usr/sbin/vmo -r -o v_pinshm=1
Oracle recommends specifying enough large pages to contain the entire SGA. The Oracle Database instance attempts to allocate large pages when the LOCK_SGA parameter is set to true. If the SGA size exceeds the size of memory available for pinning, or large pages, then the portion of the SGA exceeding these sizes is allocated to ordinary shared memory.
Many of the TPC benchmarks use lock_sga=true

0 comments:

Loading