ORACLE核心引數
伺服器記憶體為4G的情況下
修改/etc/sysctl.conf檔案 (ROOT賬戶)
kernel.shmmax = 2147483648
//公式:2G*1024*1024*1024=2147483648(位元組)
//表示最大共享記憶體,如果小的話可以按實際情況而定,一般為實體記憶體的一半(單位:位元組)
kernel.shmmni=4096
//表示最小共享記憶體固定4096KB(由於32位作業系統預設一頁為4K)
kernel.shmall=1048576
//公式:4G*1024*1024/4K = 1048576(頁)
//表示所有記憶體大小(單位:頁)
kernel.sem=250 32000 100 128
//4個引數依次是SEMMSL:每個使用者擁有訊號量最大數,SEMMNS:系統訊號量最大數,SEMOPM:每次semopm系統呼叫運算元,SEMMNI:系統辛苦量集數最大數。這4個引數為固定內容大小
fs.file-max=65536
//file-max固定大小65536
net.ipv4.ip_local_port_range=1024 65000
//ip_local_port_range表示埠的範圍,為指定的內容
以上步驟做完執行 /sbin/sysctl -p 使核心生效
驗證引數(root賬戶執行):
#/sbin/sysctl -a | grep shm
#/sbin/sysctl -a | grep sem
#/sbin/sysctl -a | grep file-max
#/sbin/sysctl -a | grep ip_local_port_range
最近解決了一些這方面的問題,並在網路上查詢了一些相關資料終於發現一個比較全面解釋這類問題的官方文件。本來打算當一次活雷鋒全文翻譯的,後來考慮自己英文一般,並且對於其中一些OS相關的知識也沒有深入瞭解。就保留英文大家自己去領會其中的要領,自己簡單總結了一下解決這類問題的關鍵點並整理一下英文原文。這個文件是oracle官方技術支援網站Metalink的資料,裡面引用了一些其它的文件例如NOTE:115235.1 。
對於unix作業系統中Semaphores問題只是針對和oracle相關問題作一些解釋。對於訊號量和共享記憶體段引數在不同的系統中可能有不同的引數對應,具體你去查詢對應的OS文件。
在解決這類問題的時候我發現大部分問題都是因為在安裝oracle時沒有仔細閱讀針對指定OS的安裝說明造成安裝例項失敗,一般oracle的官方文件都詳細說明在對應作業系統上如何設定這些核心引數。還有就是因為其他原因OS管理人員調整了引數,但是沒有通知DBA,一旦oracle崩潰再次重新啟動的時候就可能因為新的核心引數不合適而無法啟動。 如果是oracle意外停機之後重新啟動不成功,並出現類似ora-27123的錯誤那麼一定要詢問是否有其他人修改過核心引數,有時候你沒有修改並不代表其他人沒有修改喲,我遇到過不少這樣的情況!
1、與oracle相關的訊號量和共享記憶體段引數
一般unix系統中和訊號量相關的是三個引數SEMMNI SEMMSL SEMMNS。他們相互關聯決定系統可以分配的訊號量。Oracle使用訊號量完成內部程式之間的通訊。
關於共享記憶體段使用shmmx引數進行總體控制。它指定了系統可以分配的共享記憶體段最大大小,實際並沒有分配那麼多隻是給出一個可以使用的最大限制。
對於類核引數的修改必須要重新啟動系統之後才會生效。
2、出現訊號量和共享記憶體段相關問題的情況
oracle只有在startup nomount的時候才會請求os的這些資源,用於建立SGA和啟動後臺程式。
有些情況下因為oracle崩潰之後os沒有清除oracle分配的SGA,也可能造成共享記憶體段不足,需要人工清除。
3、如何解決相關的問題
你可以簡單的修改init引數減少oracle對共享記憶體段和訊號量的需求。
對於控制訊號量的三個引數SEMMNI SEMMSL SEMMNS 。最終可以使用的訊號量由下面公式 提取 (semmsl * semmni) 或者 semmns中最小的值。
例如在linux下. 進入目錄/proc/sys/kernel;用cat命令或more命令檢視semaphore當前引數的值:
cat sem
命令執行後將會出現如下的結果:
250 32000 32 128
其中, 250 是引數SEMMSL的值,32000是引數SEMMNS的值, 32是引數SEMOPM的值,而128則是引數SEMMNI的值。250*128=32000
對於oracle7需要訊號量的設定等於init中processes的設定。對於8i 9i需要等於processes*2。
對於訊號量引數的設定一定要小心,因為不正確的設定可能會讓系統使用預設值。這個值一般比oracle系統要求的低。在HP unix上遇到過這樣的問題,當時在引數配置的時候指定兩個不同的sem-mni造成系統使用預設的設定。
對於共享記憶體段,系統的設定至少要等於SGA的大小。
Semaphores and Shared Memory
BULLETIN Status: PUBLISHED Content Type: TEXT/PLAIN Creation Date: 05-AUG-2001
Last Revision Date: 05-AUG-2002
PURPOSE-------
To provide an overview of shared memory and semaphores, answer common questions related to these OS resources and provide links to more detailed information.
SCOPE & APPLICATION
-------------------
This document is intended for anyone who is responsible for creating or
administering an Oracle Database. It is intended to compliment the semaphore and
shared memory information already provided in the Oracle Installation Guides.
關於訊號量和共享記憶體段的背景知識
----------------------------------------------------------------------------------
Semaphores and shared memory are two very distinct sets of Operating System
resources. Semaphores are a system resource that Oracle utilizes for interprocess
communication and they occupy a relatively small memory space, while shared memory is utilized to contain the SGA and can garner a large portion of physical memory.
How many of these resources are available and how they are allocated is controlled
by the configuration of the operating system kernel('kernel' referring to the
centralized core components of the underlying operating system).
There are three OS kernel parameters that work together to limit semaphore
allocation and one OS kernel paramater that dictates the maximum size of a shared
memory segment.
Operating System kernel parameters generally cannot be tuned on the fly. If they
are modified, the changes will not take place until the system is rebooted.
Remember also that the kernel parameters related to semaphores and shared memory represent 'high-water' marks. Meaning that the OS will not automatically
allocate a given amount, but will allow up to that given amount to be available
upon request.
什麼時候訊號量和共享記憶體段問題最有可能發生
----------------------------------------------------------------------------------
Both semaphore or shared memory errors appear primarily at instance startup (The
'startup nomount' stage specifically). This is the only time that Oracle tries to
acquire semaphores and shared memory for the instance. Errors related to
semaphores or shared memory rarely appear during normal database operations.
The most common circumstance in which these errors occur is during the creation of
a new database.
Sometimes when an Oracle instance crashes, however, it's shared memory segments may not be released by the OS. This limits the overall amount of shared memory available for the instance to start up again. In this case, you will need to remove those segments manually.
如何解決訊號量和共享記憶體段問題:
How to resolve semaphore and shared memory errors:
----------------------------------------------------------------------------------
In addressing both semaphore and shared memory errors at instance startup, there
are two separate areas that should be considered for reconfiguration.
The first and most simple fix is to modify the init.ora to reduce the number of semaphores or the amount of shared memory Oracle will try to grab at instance startup.
If your situation requires that you not reduce the appropriate init.ora
parameters, you will have to modify the operating system kernel to allow the OS to
provide more semaphores or allow larger shared memory segments.
SEMAPHORES
================================================== ================================
IMPORTANT NOTE: ORACLE DOES NOT UTILIZE SEMAPHORES ON AIX OR DIGITAL/TRU64.
與訊號量相關的的ORA錯誤
What kind of ORA errors are related to semaphores?
----------------------------------------------------------------------------------
'Out of memory' type errors are seldom related to semaphores. Error messages which reference a 'SEMM*****' function are related to semaphores.
IMPORTANT NOTE: THESE ERRORS ONLY OCCUR AT INSTANCE STARTUP.
ORA-7250 "spcre: semget error, unable to get first semaphore set."
ORA-7279 "spcre: semget error, unable to get first semaphore set."
ORA-7251 "spcre:semget error, could not allocate any semaphores."
ORA-7252 "spcre: semget error, could not allocate any semaphores."
ORA-7339 "spcre: maximum number of semaphore sets exceeded."
[NOTE:115235.1] Resolving ORA-7279 or ORA-27146 errors when starting instance
VERY COMMON On Oracle8i and Oracle9i:
ORA-3113 "end-of-file on communication channel" at instance startup.
ORA-27146 "post/wait initialization failed"
[NOTE:115235.1] Resolving ORA-7279 or ORA-27146 errors when starting instance
If you want a very specific explanation of causes for the above errors, refer to:
[NOTE:15566.1] TECH Unix Semaphores and Shared Memory Explained
However, while their exact cause varies, all these error messages indicate that
your init.ora is configured to grab more semaphores than the OS has available.
If you configure your OS as indicated in the following sections, you will not get any of the errors indicated above.
成功配置訊號量的步驟
The Basic Steps to Semaphore Success:
----------------------------------------------------------------------------------
1. Understand The Basic Concept Behind Semaphores
2. Understand How Many Semaphores Your Oracle Instance(s) Will Attempt to Grab
From The Operating System.
3. Configure Your OS Kernel To Accomodate all Your Oracle Instance(s) And also
Allow For Future Growth.
[STEP 1] How are semaphores released by the OS for use by an application?
----------------------------------------------------------------------------------
There are 3 OS kernel parameters that work together to limit semaphore allocation.
When an application requests semaphores, the OS releases them in 'sets'.
Illustrated here as 2 sets: +---+ +---+
| | | |
| | | |
+---+ +---+
Controlled by SEMMNI -->OS limit on the Number of Identifiers or sets.
Each set contains a tunable number of individual semaphores.
Illustrated here as 2 semaphores per semaphore set: +---+ +---+
| S | | S | S | | S |
+---+ +---+
Controlled by SEMMSL -->The number of semaphores in an identifier or
set.(Semaphore List)
Ultimately however, the OS can limit the total number of semaphores available
from the OS. Controlled by:
SEMMNS --> The total Number of Semaphores allowed system wide.
For instance: Let's say SEMMNI = 100000000 and SEMMSL= 100000000 while SEMMNS=10
Even though SEMMNI is 100000000 and SEMMSL is 100000000, the max # of semaphores available on your system will only be 10, because SEMMNS is set to 10.
Inversely: Let's say SEMMNI = 10 and SEMMSL = 10 while SEMMNS=
100000000000000000000000000 Because SEMMNI is 10 and SEMMSL is 10, the max # of semaphores avail on your system will only be 100 or (10 X 10), despite what SEMMNS is set too.
THIS NOTION CAN BE SUMMARIZED BY THE FOLLOWING STATEMENT:
The max # of semaphores that can be allocated on a system will be the lesser of:
(semmsl * semmni) or semmns.
On HP: semmsl is hardcoded to 500. [NOTE:74367.1] HP-UX SEMMSL Kernel Parameter
SEMMNI, SEMMSL & SEMMNS are the basic names for OS semaphore kernel parameters,the full name may vary depending on your OS. Consult your OS specific Oracle Install guide.
[NOTE:116638.1] Understanding and Obtaining Oracle Documentation)
[STEP 2] How many semaphores will my Oracle instance(s) require?
----------------------------------------------------------------------------------
With Oracle7: The number of semaphores required by an instance is equal to the
setting the 'processes' parameter in the init.ora for the instance.
With Oracle8, Oracle8i and Oracle9i: The number of semaphores required by an
instance is equal to 2 times the setting of the 'processes' parameter in the init.ora for the instance. Keep in mind, however, that Oracle only momentarily grabs 2 X 'processes' then releases half at instance startup. This measure was apparently introduced to ensure Oracle could not exhaust a system of semaphores.
Oracle may also grab a couple of additional semaphores per instance for internal
use.
[STEP 3] Configure your OS kernel to accomodate all your Oracle instances.
----------------------------------------------------------------------------------
There seems to be some confusion of how to deal with lack of semaphore errors. The
popular theory being that if Oracle cannot find enough semaphores on a system,
increase semmns. This is not always the case, as illustrated in [STEP 1].
Once you have determined your semaphore requirements for Oracle and compensated for future growth, contact your System Administrator or OS vendor for assistance in modifying the OS kernel.
What should I set 'semmni', 'semmsl' & 'semmns' to?
----------------------------------------------------------------------------------
Oracle Support typically does not recommend specific values for semaphore kernel
parameters. Instead, use the information provided in this document to set the parameters to values that are appropriate for your operating environment.
For more info please look at the following note : [NOTE:15654.1] TECH: Calculating
Oracle's SEMAPHORE Requirements
快速解決訊號量問題
Quick fix for resolving lack of semaphore errors:
----------------------------------------------------------------------------------
Reduce the number of semaphores Oracle requires from the OS.
The first and most simple fix is to modify the init.ora to reduce the
number of semaphores or the amount of shared memory Oracle will try to grab at
instance startup.
Keep in mind, with Oracle8, we grab 2 X 'processes' then release half. This measure
was apparently introduced to ensure Oracle could not exhaust a system of semaphores.
如何查詢OS配置的訊號量
How can I find out how my OS kernel is configured for semaphores?
----------------------------------------------------------------------------------
The files that are used to tune kernel parameters varies depending on your
Operating System. Consult your system administrator or OS vendor, because viewing the system file may not show accurate information about the runtime values.
However, an important point to remember is that if a typographical error is made
while editing these files, the OS will defer to a default value which is usually to low to accomodate Oracle. So it's a good idea to check runtime values with utilities like '/etc/sysdef'.
I've tuned my OS kernel parameters, but I am still having semaphore problems....
----------------------------------------------------------------------------------
常見問題!!
This may mean that you made a typographical error or did not rebuild your
Operating System kernel correctly(if a typographical error is made while editing these files, the OS will defer to a default value which is usually to low to accomodate Oracle).
On Solaris, check current OS kernel values with this command:
> /etc/sysdef|grep -i semm
If these values do not reflect what you put in your 'system' file, you likely made a typographically error.
On HP, be sure the OS kernel was rebuilt correctly and that the OS was booted off the correct file. Contact your System Administrator or HP for more information.
在Linux系統上
進入目錄/proc/sys/kernel;用cat命令或more命令檢視semaphore當前引數的值:
cat sem
命令執行後將會出現如下的結果:
250 32000 32 128
其中, 250 是引數SEMMSL的值,32000是引數SEMMNS的值, 32是引數SEMOPM的值,而128則是引數SEMMNI的值。250*128=32000
如何獲得當前正在使用的訊號量
How can I determine how many semaphores are currently being utilized?
----------------------------------------------------------------------------------
On most Unix systems, current semaphore allocation can be displayed with the OS
command 'ipcs -s'.
% ipcs -s
While good to know, this command is seldom used as part of troubleshooting semaphore errors.
SHARED MEMORY
==================================================
OS如何分配共享記憶體段
How is shared memory allocated by the OS?
----------------------------------------------------------------------------------
This process varies slightly depending on Unix platform, but the basic premise is this:
An application requests a given amount of contiguous shared memory from the OS. The OS dictates how large of a shared memory segment it will allow with the kernel
parameter SHMMAX(Shared Memory Maximum). If the amount of shared memory requested by the application is greater than SHMMAX, the OS may be granted the shared memory in multiple segments. Ideally, however, you want the amount requested by the application to be less than SHMMAX so that the application's request can be fulfilled with one shared memory segment.
SHMMAX和SGA的關係
How does SHMMAX relate to my SGA?
----------------------------------------------------------------------------------
Since the SGA is comprised of shared memory, SHMMAX can potentially limit how large your SGA can be and/or prevent your instance from starting.
What limits the size of my SGA?
----------------------------------------------------------------------------------
In no particular order.
5. The amount of Physical Memory and Swap space available on your system.
6. The kernel paramater SHMMAX.
7. Other OS specific limitations on shared memory.
Memory SHMMAX OS Limits +----------+ +----------+ +----------+
| | | | | | +------+
| | | | | | | S |
| | | | | | > | G |
| | | | | | | A |
| | | | | | +------+
+----------+ +----------+ +----------+
Some OS specific limitations are discussed in the following documents:
"Oracle Administrator's Reference" available on the Oracle Install CD
Additionallly:
HP-UX: [NOTE:77310.1] HP-UX Large SGA support for HP, Memory Windows
[NOTE:69119.1] HP-UX SGA Sizing Issues on HP-UX
Solaris: [NOTE:61896.1] SOLARIS: SGA size, sgabeg attach address and Sun
與共享記憶體當相關的錯誤
What kind of ORA errors are related to shared memory?
----------------------------------------------------------------------------------
Error Messages referencing a 'SHMM****' function are related to shared memory.
ORA-7306, ORA-7336, ORA-7329, ORA-7307, ORA-7337, ORA-7320, ORA-7329, ORA-7334
VERY COMMON IN 8i: ORA-27100 "shared memory realm already exists" ORA-27102 "out of memory"
ORA-27125 "unable to create shared memory segment" and/or "linux 43 identifier removed"
ORA-27123 "unable to attach to shared memory segment"
[NOTE:115753.1] UNIX Resolving the ORA-27123 error
[NOTE:1028623.6] SUN SOLARIS: HOW TO RELOCATE THE SGA
如何設定SHMMAX
What should I set 'shmmax' to?
----------------------------------------------------------------------------------
On some Unix platforms, the Install Guide recommends specific values. Previous
versions of the Install Guide recommended setting SHMMAX to .5 *(physical memory present in machine). Most recently it's been suggested SHMMAX be set to 4294967295 (4GB). This may not seem appropriate, particularly if the system has considerably less physical memory available, but it does prevent you from having to modify your system kernel everytime a new instance is created or additional physical memory is added to the system. Remember that SHMMAX is a high water mark, meaning that the OS will attempt to allow up to that amount for an application.
解決缺少共享記憶體段的問題
Quick fix for resolving lack of shared memory errors:
-----------------------------------------------------------------------------------
NOTE: If you have never configured your OS kernel for shared memory, you cannot employ this 'Quick Fix'. You will have to first configure the OS kernel. The amount of shared memory Oracle requests is roughly equal to the size of the SGA. The first and most simple fix is to modify the init.ora to reduce the amount of shared memory Oracle will try to grab at instance startup.
This document lists the init.ora parameters that contribute to the size
of the SGA:
[NOTE:1008866.6] HOW TO DETERMINE SGA SIZE (8.0, 8i, 7.x)
oracle崩潰之後重新啟動失敗的問題
My instance crashed. When I try to restart it, I receive errors related to shared
memory. What should I do?
-----------------------------------------------------------------------------------
This may indicate that the shared memory segment associated with the SGA of the crashed instance is still in memory. In this case it may be appropriate to manually remove the segment using OS commands.
THIS PROCESS SHOULD NOT BE ATTEMPTED UNLESS YOU FULLY UNDERSTAND THE CONCEPTS BEHIND IT!!!
The basic steps are:
1. Identify the shared memory segment that is 'stuck' in memory.
2. Remove the 'stuck' shared memory segment using the OS command 'ipcrm'.
[NOTE:68281.1] DETERMINING WHICH INSTANCE OWNS WHICH SHARED MEMORY & SEMAPHORE SEGMENTS
[NOTE:69642.1] also describes this process - Step 9.
[NOTE:123322.1] SYSRESV UTILITY: This note describes the new 8i 'sysresv' utility that can be used on Solaris to associate a given ORACLE_SID with it's shared memory segment(s). .
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2112447/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 核心引數Oracle
- 談談ORACLE核心引數Oracle
- oracle核心引數意義Oracle
- oracle rac 核心引數詳解Oracle
- Oracle和SUN Solaris核心引數Oracle
- Linux核心引數以及Oracle引數調整(updated)LinuxOracle
- Linux 核心引數優化(for oracle)Linux優化Oracle
- Oracle和SUN Solaris核心引數(轉)Oracle
- Linux 核心引數 和 Oracle相關引數調整LinuxOracle
- Linux 核心引數及Oracle相關引數調整LinuxOracle
- (轉)Linux 核心引數及Oracle相關引數調整LinuxOracle
- oracle相關的linux核心引數OracleLinux
- 核心引數(轉)
- Oracle中的sysctl.conf核心引數Oracle
- 安裝oracle時核心引數的含義Oracle
- oracle sga配置相關的os 核心引數Oracle
- Linux核心引數(如kernel.shmmax)及Oracle相關引數調整LinuxHMMOracle
- ORACLE安裝核心引數配置_linux平臺OracleLinux
- linux 核心引數Linux
- Linux核心引數Linux
- linux 跟oracle相關的系統核心引數?LinuxOracle
- Oracle建庫必備的核心初始化引數Oracle
- (轉)redhat下安裝oracle,設定redhat核心引數RedhatOracle
- oracle安裝linux時的核心引數解釋OracleLinux
- Oracle引數-隱藏引數Oracle
- 核心引數意義(轉)
- oracle 引數Oracle
- solaris10中安裝oracle核心引數的調整Oracle
- Oracle 效能最佳化之核心的shmall 和shmmax 引數OracleHMM
- linux中與Oracle有關的核心引數詳解LinuxOracle
- 與oracle緊密相關的unix/linux核心引數OracleLinux
- Linux核心引數調優Linux
- linux核心啟動引數Linux
- linux中與Oracle有關的核心引數詳解(zhuan)LinuxOracle
- linux系統基於oracle的核心引數配置說明LinuxOracle
- Oracle 11g 在solaris 10 上核心引數的設定Oracle
- RED HAT 7.3裝Oracle8.1.7配置什麼核心引數(轉)Oracle
- Oracle引數檔案解析——引數解析Oracle