【生產排故】Oracle 11g 異機rman恢復報錯ORA-302failure occurred at sskgpcreates

在這裏插入圖片描述
【引言】
今天,使用Oracle的11g做異庫恢復,第一步使用源端生產庫的pfile文件在目標端使用startup nomount命令啓拉庫時,報錯了如下信息:

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 9 17:49:14 2020

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@ETHANDB> startup nomount;
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpcreates

根據提示,會誤以爲是磁盤空間不足 (No space left on device), 其實最後的提示發現是信號量參數設置問題。

分析思路:

查閱Oracle官方文檔,查看數據庫初始參數和Kernel參數的關係.

db_block_buffers            shmmax
db_files (maxdatafiles)     nfile, maxfiles
large_pool_size             shmmax
log_buffer                  shmmax
processes                   nproc, semmsl, semmns
shared_pool_size            shmmax
Common Unix Kernel Parameter Definitions
The following Kernel Parameters tend to be generic across most Unix platforms:

通常情況下,如下內核參數就可以滿足大多數Unix系統。

maxfiles - Soft file limit per process.
maxuprc - Maximum number of simultaneous user processes per userid.
nfile - Maximum number of simultaneously open files systemwide at any given time.
nproc - Maximum number of processes that can exist simultaneously in the system.
shmmax - The maximum size(in bytes) of a single shared memory segment.
shmmin - The minimum size(in bytes) of a single shared memory segment.
shmmni - The number of shared memory identifiers.
shmseg - The maximum number of shared memory segments that can be attached by a process.
semmns - The number of semaphores in the system.
semmni - The number of semaphore set identifiers in the system; determines the number of semaphore sets that can be created at any one time.
semmsl - The maximum number of sempahores that can be in one semaphore set. It should be same size as maximum number of Oracle processes.

看一個官方案例 vi /etc/sysctl.conf

#System default settings live in /usr/lib/sysctl.d/00-system.conf.
#To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#For more information, see sysctl.conf(5) and sysctl.d(5).
#ORACLE SETTING
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 15728640
kernel.shmmax = 64424509440
kernel.shmmni = 4096
kernel.sem = 5010 641280 5010 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

接下來再介紹下各參數的主要用途:
1.kernel.shmall: 共享內存頁數的最大值
Linux共享內存頁大小爲4KB, 共享內存段的大小都是共享內存頁大小的整數倍。一個共享內存段的最大大小是16G,需要共享內存頁數是 16GB/4KB=16777216KB/4KB=4194304(頁)

2.kernel.shmmax:單個共享內存段的最大值
shmmax是核心參數中最重要的參數之一,用於定義單個共享內存段的最大值,shmmax設置應足夠大,能在一個共享內存段下容納下整個的SGA,設置的過低可能會導致需要創建多個共享內存段,可能導致系統性能的下降。

3. kernel.shmmni:共享內存段的最大數量
注意該參數不是shmmin,是shmmni,shmmin 表示內存段最小大小 ) shmmni缺省值4096 足夠。 shmmax(bytes) = shmmni(page size, default 4k) * shmall (page的個數)

4) semop 系統調用(函數)提供了利用一個 semop 系統調用完成多項信號操作的功能。

一個信號集能夠擁有每個信號集中最大數量的SEMMSL 信號,因此建議設置 SEMOPM 等於SEMMSL 。 Oracle 建議將 SEMOPM 的值設置爲不少於 100 。 SEMMNI :內核參數用於控制整個 Linux 系統中信號集的最大數量。 Oracle 建議將 SEMMNI 的值設置爲不少於 100 。

裝過Oracle的親都知道,linux系統中很好改,在 vi /etc/sysctl.conf 裏,重新加載生效是 sysctl -p即可。

注意:Linux系統中設定完這些數據後,必須使用sysctl -p 生效。

根據上述介紹,processes設置過大,會報如上錯誤;怎麼解決吶?

兩種方式:
方式1 process數改小;方式2調整系統參數semmns值。
通常,我們會先嚐試方式1,但有時候生產需求要求process不能調小,只能只用方式2修改semmns值。

但該系統報錯爲HP-UX系統環境,HP-UX系統下並沒有Linux的 /etc/sysctl.conf 文件,也不能使用命令 sysctl -p。

系統信息如下:

#uname -a
HP-UX crm-tdb B.11.31 U ia64 2272784454 unlimited-user license

如果要通過修改方式2調整系統參數semmns值來解決,該咋弄?

作爲背景知識,這裏先介紹下HP-UX環境中的內核參數,看下官方手冊。

Configuring Kernel Parameters on HP-UX Systems
During installation, you can generate and run the Fixup script to check and set the kernel parameter values required for successful installation of the database. This script updates required kernel packages if necessary to minimum values.
If you cannot use the Fixup scripts, then verify that the kernel parameters shown in the following table are set to values greater than or equal to the minimum value shown. The procedure following the table describes how to verify and set the values manually.

Note:
The kernel parameter values in this section are minimum values only. For production database systems, Oracle recommends that you tune these values to optimize the performance of the system. Refer to your operating system documentation for more information about tuning kernel parameters.

官方推薦值,如下圖:
image.png
For HP-UX Itanium:

Enter the following command to start the kcweb application:
#/usr/sbin/kcweb -F

Check the value or formula specified for each of these parameters and, if necessary, modify that value or formula.

If necessary, refer to the kcweb online Help for more information about completing this step.

Note:
If you modify the value of a parameter that is not dynamic, then you must restart the system.


修改過程:
root用戶使用命令:

```bash
#/usr/sbin/kcweb -F

按照一步步提示,修改semmns,最終修改如下:
image.png

需要注意的是:
上述參數爲靜態參數,如果做了修改,爲使其生效,需要重啓服務器。

修改參數semns後,再次使用源端生產庫的pfile文件在目標端使用startup nomount命令啓拉庫成功。

【總結】
1.本來一很小的問題,整個查資料和處理過程還是有點曲折; linux系統上很簡單一條指令,到了HP-UX上重啓服務器才能修改,很是折騰了一番;
2.事無大小,需用心做,多鑽研。

以下是個人微信公衆號“一森咖記”,歡迎關注
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章