数据库实例自动crash并报ORA-27157、ORA-27300等错误

本文解决了一个在RHEL7.2上安装12CRAC数据库后,其中一个实例频繁自动崩溃的问题。错误信息显示与systemd-logind服务移除IPC对象有关。通过调整/etc/systemd/logind.conf中的RemoveIPC参数为no,可以避免此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址

rhel7.2上安装12C RAC数据库后,其中一个数据库实例经常会自动crash。查看alert日志发现以下错误信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Errors  in  file  /d12/app/oracle/diag/rdbms/rac12c/rac12c2/trace/rac12c2_j000_21047 .trc:
ORA-27157: OS post /wait  facility removed
ORA-27300: OS system dependent operation:semop failed with status: 43
ORA-27301: OS failure message: Identifier removed
ORA-27302: failure occurred at: sskgpwwait1
Fri Sep 09 16:50:53 2016
Errors  in  file  /d12/app/oracle/diag/rdbms/rac12c/rac12c2/trace/rac12c2_rmv0_20798 .trc:
ORA-27157: OS post /wait  facility removed
Fri Sep 09 16:50:53 2016
Errors  in  file  /d12/app/oracle/diag/rdbms/rac12c/rac12c2/trace/rac12c2_q005_21328 .trc:
ORA-27157: OS post /wait  facility removed
ORA-27300: OS system dependent operation:semop failed with status: 43
ORA-27301: OS failure message: Identifier removed
ORA-27302: failure occurred at: sskgpwwait1

 

错误原因描述:

在rhel7.2中,systemd-logind服务引入了一个新特性:在一个user完全退出OS后会remove掉所有的IPC对象。 
该特性由/etc/systemd/logind.conf参数文件中RemoveIPC选项来控制。详细请看man logind.conf(5)。

在rhel7.2中,RemoveIPC的默认值是yes

因此,当最后一个oracle或者grid用户退出时,操作系统会remove掉这个user的shared memory segments和semaphores
而Oracle ASM和database的SGA需要使用 shared memory segments,因此remove shared memory segments将会crash掉Oracle ASM和database instances。

请参考Redhat bug 1264533 - https://bugzilla.redhat.com/show_bug.cgi?id=1264533

这个问题会影响使用shared memory segments和semaphores的所有应用,因此,Oracle ASM 实例和Oracle Database 实例均受到影响。
oel7.2为了避免这个问题,在/etc/systemd/logind.conf配置文件中明确设置RemoveIPC为no。

 

该问题会导致的现象:

1
2
3
1) Installing 11.2 and 12c GI /CRS  fails, because ASM crashes towards the end of the installation.
2) Upgrading to 11.2 and 12c GI /CRS  fails.
3) After Redhat Linux is upgraded to 7.2, 11.2 and 12c ASM and database instances crash.

systemd-logind可能会在任何时候remove IPC对象,发生错误的时候对应的日志现象也不同。比如:

1
2
3
4
5
Most common error that occurs is that the following is found  in  the asm or database alert.log:
ORA-27157: OS post /wait  facility removed
ORA-27300: OS system dependent operation:semop failed with status: 43
ORA-27301: OS failure message: Identifier removed
ORA-27302: failure occurred at: sskgpwwait1

  

1
2
3
The second observed error occurs during installation and upgrade when asmca fails with the following error:
KFOD-00313: No ASM instances available. CSS group services were successfully initilized by kgxgncin
KFOD-00105: Could not  open  pfile  'init@.ora'

  

1
2
3
4
5
6
7
8
9
The third observed error occurred during installation and upgrade:
Creation of ASM password  file  failed. Following error occurred: Error  in  Process:  /d12/app/12 .1.0 /grid/bin/orapwd
 
  Enter password  for  SYS:
 
OPW-00009: Could not establish connection to Automatic Storage Management instance
 
2015 /11/20  21:38:45 CLSRSC-184: Configuration of ASM failed
2015 /11/20  21:38:46 CLSRSC-258: Failed to configure and start ASM

  

1
2
3
The fourth observed error is the following message is found  in  the  /var/log/messages  file  around the  time  that asm or database instance crashed:
Nov 20 21:38:43 testc201 kernel: traps: oracle[24861]  trap  divide error
ip:3896db8 sp:7ffef1de3c40 error:0  in  oracle[400000+ef57000]

  

修改方法:

1).设置/etc/systemd/logind.conf中RemoveIPC=no
2).重启服务器或者重启systemd-logind
重启systemd-logind:

1
2
# systemctl daemon-reload
# systemctl restart systemd-logind

  

MOS Doc:

ALERT: Setting RemoveIPC=yes on Redhat 7.2 Crashes ASM and Database Instances as Well as Any Application That Uses a Shared Memory Segment (SHM) or Semaphores (SEM) (Doc ID 2081410.1)

<think>好的,我现在要解决用户在Linux环境下连接Oracle数据库时遇到的ORA-01034和ORA-27101错误。首先,我需要仔细理解用户的问题描述和提供的引用内容。 根据用户提供的引用[1]、[2]、[3],这些错误通常与Oracle实例未启动或共享内存配置问题有关。用户尝试过登录执行shutdown immediate,但同样错,提示实例未启动。这可能意味着实例根本没有运行,或者共享内存区域无法访问。 首先,ORA-01034表明Oracle不可用,通常是因为实例未启动。而ORA-27101指出共享内存域不存在,可能涉及内存配置或权限问题。结合引用中的信息,特别是引用[2]提到管理员登录后无法关闭实例,因为实例未启动,这说明用户可能在尝试操作前未正确启动实例。 接下来,我需要考虑可能的原因和解决方案: 1. **实例未启动**:用户可能没有正确启动Oracle实例。需要检查实例状态,尝试启动它。 2. **共享内存配置问题**:Oracle使用共享内存段,如果配置不正确或权限不足,会导致ORA-27101错误。 3. **环境变量设置错误**:ORACLE_SID或ORACLE_HOME未正确设置,导致实例无法识别。 4. **权限问题**:运行Oracle进程的用户(通常是oracle用户)没有足够的权限访问共享内存或相关文件。 5. **文件路径错误**:某些关键文件(如参数文件、控制文件)的路径不正确,导致实例无法启动。 6. **内存不足**:系统可用内存不足,无法分配共享内存区域。 接下来,我需要按照步骤逐步排查这些问题。首先检查实例状态,确认是否已启动。如果未启动,尝试启动实例。在启动过程中,可能会遇到更多错误,需要查看alert日志获取详细信息。同时,检查共享内存设置,确认Oracle用户有权访问相关资源。此外,验证环境变量是否正确配置,确保ORACLE_SID和ORACLE_HOME正确无误。如果问题依旧,可能需要检查参数文件(如init.ora或spfile)中的配置,特别是内存相关参数是否正确。最后,确认系统资源(如内存和交换空间)是否充足,避免因资源不足导致实例启动失败。 在用户提供的引用中,引用[3]提到解决方案可能涉及重新配置共享内存或调整内核参数。因此,可能需要检查/etc/sysctl.conf中的设置,如kernel.shmmax、kernel.shmall等,确保其符合Oracle的要求。同时,检查Oracle用户的权限,确保其属于正确的用户组,如dba组。 另外,用户提到之前尝试shutdown immediate时出错,这可能是因为实例未处于运行状态,无法执行关闭操作。需要先启动实例,然后再进行关闭或其它操作。 总结,解决步骤可能包括: - 检查启动Oracle实例 - 验证环境变量和参数配置 - 检查共享内存设置和权限 - 查看日志文件以获取详细错误信息 - 调整内核参数和Oracle配置 在回答时,需要将这些步骤详细列出,给出具体的命令和检查方法,帮助用户逐步排查问题。同时,要确保命令的正确性和适用性,避免因操作不当导致问题加重。最后,可能需要提供相关的参考资料或进一步的问题,帮助用户深入理解问题原因和解决方案。</think>### 分步解决 Linux 环境下 Oracle 数据库 ORA-01034 和 ORA-27101 错误指南 --- #### 一、核心错误解析 - **ORA-01034: ORACLE not available** 表示数据库实例未启动或处于异常关闭状态[^1]。 - **ORA-27101: shared memory realm does not exist** 指 Oracle 无法访问共享内存段,通常由配置错误或权限问题导致[^2]。 --- #### 二、快速诊断流程 ```mermaid graph TD A[检查实例状态] -->|未运行| B[启动实例] A -->|已运行| C[检查共享内存] B --> D[查看启动日志] C --> E[验证内存配置] D --> F[分析错误详情] E --> G[调整内核参数] ``` --- #### 三、具体操作步骤 ##### 1. **验证实例状态** ```bash # 以 oracle 用户执行 su - oracle sqlplus / as sysdba SQL> SELECT status FROM v$instance; # 若返回 "STARTED" 或 "MOUNTED" 表示未完全打开 # 若返回空值说明实例未启动 ``` ##### 2. **强制启动实例** ```bash # 清理残留进程 ps -ef | grep ora_ | grep -v grep | awk '{print $2}' | xargs kill -9 # 分步启动数据库 sqlplus / as sysdba SQL> startup nomount; -- 启动到 NOMOUNT 状态 SQL> alter database mount; -- 挂载数据库 SQL> alter database open; -- 打开数据库 ``` ##### 3. **共享内存配置检查** ```bash # 查看当前共享内存分配 ipcs -m # 验证内核参数 (需 root 权限) sysctl -a | grep -E 'shmmax|shmall|shmmni' ``` - **关键参数要求**: - `kernel.shmmax >= 物理内存的 50%`(建议值) - `kernel.shmall >= 总物理内存/页大小`(页大小通过 `getconf PAGE_SIZE` 查看) - `kernel.shmmni >= 4096` ##### 4. **修正配置示例** ```bash # 临时修改(立即生效) sudo sysctl -w kernel.shmmax=4294967296 # 4GB sudo sysctl -w kernel.shmall=2097152 # 页大小4KB时对应8GB # 永久修改(写入 /etc/sysctl.conf) echo "kernel.shmmax=4294967296" | sudo tee -a /etc/sysctl.conf echo "kernel.shmall=2097152" | sudo tee -a /etc/sysctl.conf sudo sysctl -p ``` ##### 5. **权限修复操作** ```bash # 确认 oracle 用户权限 id oracle # 应包含 dba 组 # 重建共享内存段 sudo rm -f /dev/shm/* sudo chown oracle:dba /dev/shm sudo chmod 6755 /dev/shm ``` ##### 6. **关键日志分析** ```bash # 查看 alert 日志(路径示例) tail -100f $ORACLE_BASE/diag/rdbms/${ORACLE_SID,,}/${ORACLE_SID}/trace/alert_${ORACLE_SID}.log # 常见错误线索: # - ORA-00205: error in identifying control file # - ORA-03113: end-of-file on communication channel ``` --- #### 四、进阶故障排查 ##### 1. **参数文件验证** ```sql # 检查使用的 spfile/pfile SQL> show parameter spfile; # 若使用 pfile 需检查路径正确性 SQL> create pfile from spfile; -- 生成可读文本文件 vi $ORACLE_HOME/dbs/init${ORACLE_SID}.ora ``` ##### 2. **内存泄漏检测** ```bash # 检查共享内存段残留 ipcs -m | grep -v oracle | awk '{print $2}' | xargs -n1 ipcrm -m ``` ##### 3. **环境变量确认** ```bash # 检查关键变量 echo $ORACLE_SID # 必须与实际实例名一致 echo $ORACLE_HOME # 必须指向正确安装路径 echo $LD_LIBRARY_PATH # 应包含 $ORACLE_HOME/lib ``` --- #### 五、特殊场景处理 | 场景 | 解决方案 | |------|----------| | **RAC 环境** | 检查 `crsctl stat res -t` 确认集群资源状态 | | **ASM 存储** | 使用 `asmcmd lsctl` 验证磁盘组挂载 | | **容器数据库 (CDB)** | 确认 PDB 已正确打开:`ALTER PLUGGABLE DATABASE ALL OPEN;` | --- #### 六、预防措施 1. **创建启动监控脚本** ```bash #!/bin/bash if ! pgrep -f ora_pmon_${ORACLE_SID} >/dev/null; then echo "$(date): 检测到实例停止,尝试重启..." >> /var/log/oracle_monitor.log su - oracle -c "sqlplus / as sysdba <<EOF startup; exit; EOF" fi ``` 2. **配置 systemd 服务单元** ```ini # /etc/systemd/system/oracle.service [Unit] Description=Oracle DB After=network.target [Service] Type=forking User=oracle Environment="ORACLE_SID=ORCL" ExecStart=/u01/app/oracle/product/12.2.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.2.0/dbhome_1 ExecStop=/u01/app/oracle/product/12.2.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.2.0/dbhome_1 Restart=on-failure [Install] WantedBy=multi-user.target ``` --- ### 相关问题 1. **如何通过 Crash Recovery 修复因突然断电导致的数据库损坏?** 2. **Oracle 数据库在 Docker 容器中运行时出现 ORA-27101 应如何排查?** 3. **怎样配置 HugePages 来优化 Oracle 共享内存管理?** [^1]: 实例未启动时访问数据库会触发 ORA-01034 [^2]: 共享内存配置错误会导致操作系统级资源访问失败
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值