因訊號量問題導致ORA-27154無法啟動資料庫,ora-27154資料庫

來源:互聯網
上載者:User

因訊號量問題導致ORA-27154無法啟動資料庫,ora-27154資料庫

測試庫執行startup時提示(11.2.0.1):


查詢ORA-27154的錯誤

Error:  ORA-27154Text:   post/wait create failed ---------------------------------------------------------------------------Cause:  internal error, multiple post/wait creates attempted simultaneously Action: check errno and contact Oracle Support
提示是一個內部錯誤,多個post/wait同時請求。


df查看磁碟空間還有很多,不存在佔滿的情況


查看報錯中的semget含義

提示segmet的含義是get a semaphore set identifier,即擷取一個訊號量集標識符。說明此錯誤可能和未獲得訊號量有關,No space left on device不是指儲存空間,而是指訊號量資源。


從MOS的介紹看(949468.1),一系列的報錯出現10.1.0.2到11.2.0.2的範圍內。給出了樣本:

$ ipcs -ls

------ Semaphore Limits --------

max number of arrays = 128

max semaphores per array = 250

max semaphores system wide = 32000

max ops per semop call = 100

semaphore max value = 32767

產生的原因是,從原理上看,32000訊號量可用,一個訊號量標識符能包含最大250個訊號量。但是ipcs命令展示每個訊號量標識符僅能讓Oracle包含最大156個訊號量。

$ ipcs << 這個樣本中沒有啟動額外執行個體的前提下,大約包含100個訊號量字元集

..

------ Semaphore Arrays --------

key semid owner perms nsems

0x450e15bd 0 root 666 1

0x0000cace 32769 root 666 1

0x358b172c 327683 oracle 660 104

0x9053d038 11075588 oracle 660 156

0x9053d039 11108357 oracle 660 156

0x9053d03a 11141126 oracle 660 156

0x9053d03b 11173895 oracle 660 156

..

那麼可用的最大訊號量就是156*128=19968,不是32000。

解決方案增加可包含的訊號量,這雷根據SEMMNI參數來調整設定。

1. 查詢當前kernel的訊號量參數值。

# /sbin/sysctl -a | grep sem

2. 修改/etc/sysctl.conf檔案的SEMMNI參數。

從kernel.sem = 250 32000 100 128修改為kernel.sem = 250 32000 100 200

3. 使用# /sbin/sysctl -p讓修改生效。


結合到我這裡的情況,首先查看ipcs的結果:


資料庫啟動後,需要從作業系統上分配共用記憶體和訊號量,訊號量就相當於OS的記憶體鎖,類似於Oracle的latch(注意Oracle的鎖和latch的區別),每個進程需要擷取作業系統記憶體時,需要先獲得訊號量才能申請記憶體。

從上述指令可以看到最大可用的訊號量是100,訊號量標識符集最大是128,呃,這裡失誤,當時沒有查看到ipcs實際的訊號量標識符集。這裡4個參數的含義:

SEMMSL         100        Defines the minimum recommended value,for initial installation only
The maximum number of sempahores that can be in one semaphore set. It should be same size as maximum number of Oracle processes.一個訊號量集中允許的最大訊號量數。需要和Oracle的process個數相同。
SEMMNS        100         Defines the maximum semaphores on the system.
This setting is a minimum recommended value, for initial installation only. The SEMMNS parameter should be set to the sum of the PROCESSES parameterfor each Oracle database, adding the largest one twice, and then adding an additional 10 for each database.
系統允許的最大訊號量數,SEMMNS參數應設定為每個資料庫的PROCESSES參數,加上兩倍的最大值,再為每個資料庫加上額外的10,算出來的總和。(注意這裡說明該值是最小的建議值)
SEMOPM        32          Defines the maximum number of operations for each semop call
每次訊號量調用的最大運算元。
SEMMNI        128         Defines the maximum number of semaphore sets in the entire system
系統中訊號量集的最大值。
可以推測SEMMNS=SEMMSL * SEMMNI。
但上述樣本中:100<>100 * 128,SEMMNS最大允許的訊號量(建議最小值)只有100,顯然不能滿足計算結果的數量。而且從Oracle官方文檔看到的對於這幾個參數的 推薦值

Configuring Kernel Parameters

Verify that the kernel parameters shown in the following table are set to values greater than or equal to the recommended value shown. The procedure following the table describes how to verify and set the values.

Parameter Value File
semmsl

semmns

semopm

semmni

250

32000

100

128

/proc/sys/kernel/sem
SEMMNS是32000,即SEMMSI(250)*SEMMNI(128)的結果。


進而可以推斷報錯提示的sskgpcreates可能和process數量有關,kernel中和該值有關的參數是SEMMNS,和上述推測的結論相同,即PROCESS過多,但允許的最大訊號量過少,兩者不匹配,導致No space left on device提示訊號量資源不足


解決方案如MOS指點的,修改訊號量參數值,可以用:

這種方式只是臨時修改,機器重啟後失效,若需要持久生效,可以修改/etc/sysctl.conf對應的參數值。


總結

1. 錯誤提示No space left on device未必表示儲存空間不足,本例中就是指的訊號量資源。

2. kernel.sem中四個參數的含義,以及SEMMNS(允許的最大訊號量)=SEMMSL(一個訊號量集允許包含的訊號量) * SEMMNI(系統允許包含的最大訊號量集)的計算關係,還有就是SEMMNS定義的是Defines the maximum semaphores on the system. This setting is a minimum recommended value,for initial installation only. 即允許的最大訊號量,但這個值是用於初始安裝的最小推薦值。

3. 藉助baidu或google甚至MOS尋找問題,可能找到解決方案,但更重要的是能夠知道原因,進而瞭解問題出現的情境,結合自己的問題,確定是同一類之後,再執行操作,一句話:要謹慎。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.