1、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(页) /表示所有内存大小(单位:页) kerne
2、l.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/s
3、ysctl -a | grep shm #/sbin/sysctl -a | grep sem #/sbin/sysctl -a | grep file-max #/sbin/sysctl -a | grep ip_local_port_range对于 unix 操作系统中 Semaphores 问题只是针对和 oracle 相关问题作一些解释。对于信号量和共享内存段参数在不同的系统中可能有不同的参数对应,具体你去查询对应的 OS 文档。在解决这类问题的时候我发现大部分问题都是因为在安装 oracle 时没有仔细阅读针对指定 OS 的安装说明造成安装实例失败,一般 oracle 的官方文档都详
4、细说明在对应操作系统上如何设置这些内核参数。还有就是因为其他原因 OS 管理人员调整了参数,但是没有通知 DBA,一旦 oracle 崩溃再次重新启动的时候就可能因为新的内核参数不合适而无法启动。 如果是 oracle 意外停机之后重新启动不成功,并出现类似 ora-27123 的错误那么一定要询问是否有其他人修改过内核参数,有时候你没有修改并不代表其他人没有修改!1、与 oracle 相关的信号量和共享内存段参数一般 unix 系统中和信号量相关的是三个参数 SEMMNI SEMMSL SEMMNS。他们相互关联决定系统可以分配的信号量。Oracle 使用信号量完成内部进程之间的通信。关于共
5、享内存段使用 shmmx 参数进行总体控制。它指定了系统可以分配的共享内存段最大大小,实际并没有分配那么多只是给出一个可以使用的最大限制。对于类核参数的修改必须要重新启动系统之后才会生效。2、出现信号量和共享内存段相关问题的情况oracle 只有在 startup nomount 的时候才会请求 os 的这些资源,用于建立 SGA 和启动后台进程。有些情况下因为 oracle 崩溃之后 os 没有清除 oracle 分配的 SGA,也可能造成共享内存段不足,需要人工清除。3、如何解决相关的问题你可以简单的修改 init 参数减少 oracle 对共享内存段和信号量的需求。对于控制信号量的三个参
6、数 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 需要信号
7、量的设置等于 init 中 processes 的设置。对于 8i 9i 需要等于processes*2。对于信号量参数的设定一定要小心,因为不正确的设置可能会让系统使用默认值。这个值一般比 oracle 系统要求的低。在 HP unix 上遇到过这样的问题,当时在参数配置的时候指定两个不同的 sem-mni 造成系统使用默认的设置。对于共享内存段,系统的设置至少要等于 SGA 的大小。Semaphores and Shared MemoryBULLETIN Status: PUBLISHED Content Type: TEXT/PLAIN Creation Date: 05-AUG-200
8、1Last Revision Date: 05-AUG-2002PURPOSE-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 oradministerin
9、g an Oracle Database. It is intended to compliment the semaphore andshared memory information already provided in the Oracle Installation Guides.关于信号量和共享内存段的背景知识-Semaphores and shared memory are two very distinct sets of Operating Systemresources. Semaphores are a system resource that Oracle utilize
10、s for interprocesscommunication 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 controlledby the configuration of the operatin
11、g system kernel(kernel referring to thecentralized core components of the underlying operating system).There are three OS kernel parameters that work together to limit semaphoreallocation and one OS kernel paramater that dictates the maximum size of a sharedmemory segment.Operating System kernel par
12、ameters generally cannot be tuned on the fly. If theyare 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 automaticallyallocate a given amou
13、nt, but will allow up to that given amount to be availableupon request.什么时候信号量和共享内存段问题最有可能发生-Both semaphore or shared memory errors appear primarily at instance startup (Thestartup nomount stage specifically). This is the only time that Oracle tries toacquire semaphores and shared memory for the ins
14、tance. Errors related tosemaphores or shared memory rarely appear during normal database operations.The most common circumstance in which these errors occur is during the creation ofa new database.Sometimes when an Oracle instance crashes, however, its shared memory segments may not be released by t
15、he 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 star
16、tup, thereare 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 appr
17、opriate init.oraparameters, you will have to modify the operating system kernel to allow the OS toprovide 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
18、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 e
19、rror, 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 i
20、nstanceVERY 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 instanceIf you want a very specific explanation of causes for the above errors
21、, refer to:NOTE:15566.1 TECH Unix Semaphores and Shared Memory ExplainedHowever, while their exact cause varies, all these error messages indicate thatyour 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 wi
22、ll not get any of the errors indicated above.成功配置信号量的步骤The Basic Steps to Semaphore Success:-1. Understand The Basic Concept Behind Semaphores2. Understand How Many Semaphores Your Oracle Instance(s) Will Attempt to GrabFrom The Operating System.3. Configure Your OS Kernel To Accomodate all Your Ora
23、cle Instance(s) And alsoAllow 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:
24、+-+ +-+| | | | | | |+-+ +-+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 identif
25、ier orset.(Semaphore List)Ultimately however, the OS can limit the total number of semaphores availablefrom the OS. Controlled by:SEMMNS The total Number of Semaphores allowed system wide.For instance: Lets say SEMMNI = 100000000 and SEMMSL= 100000000 while SEMMNS=10Even though SEMMNI is 100000000 a
26、nd SEMMSL is 100000000, the max # of semaphores available on your system will only be 10, because SEMMNS is set to 10.Inversely: Lets 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
27、 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 ParameterSEMMN
28、I, 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 Orac
29、le7: The number of semaphores required by an instance is equal to thesetting the processes parameter in the init.ora for the instance.With Oracle8, Oracle8i and Oracle9i: The number of semaphores required by aninstance is equal to 2 times the setting of the processes parameter in the init.ora for th
30、e 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 interna
31、luse.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. Thepopular theory being that if Oracle cannot find enough semaphores on a system,increase semmns. This is not always the case, as illustrated i
32、n 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 valu
33、es for semaphore kernelparameters. 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: CalculatingOracles SEMAPHORE Requirements快速解决信号量问题Quick f
34、ix 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 thenumber of semaphores or the amount of shared memory Oracle will try to grab atinstance startup.Keep in mind, with Oracle8, we gr
35、ab 2 X processes then release half. This measurewas 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 yourOperating Syst
36、em. 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 madewhile editing these files, the OS will defer to a default value which is usua
37、lly to low to accomodate Oracle. So its a good idea to check runtime values with utilities like /etc/sysdef.Ive 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 yourOperating System kernel correctly(if a
38、 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 semmIf these values do not reflect what you put in your system file, you likely
39、 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 12
40、8 其中, 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 OScommand ipcs -s. % ipcs -sWhile good to
41、 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
42、 from the OS. The OS dictates how large of a shared memory segment it will allow with the kernelparameter 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,
43、 you want the amount requested by the application to be less than SHMMAX so that the applications 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
44、 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 Administrators Reference“ available