代码改变世界

ORA-01012案例总结

2026-03-27 08:55  潇湘隐者  阅读(13)  评论(0)    收藏  举报

同事在Linux服务器上暴力测试Oracle过程中,发现Oracle实例启动过程中报"ORA-01012: not logged on"错误.如下所示

$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Mar 26 14:34:43 2026
Version 19.28.0.0.0

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

Connected.
SQL> startup
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0

检查发现已经没有ora_相关进程,如下所示:

$ ps -ef|grep ora_
oracle   1960977 1959731  0 14:36 pts/4    00:00:00 grep --color=auto ora_

但是启动Oracle实例就会遇到"ORA-01012: not logged on"这个错误信息. 其实导致ORA-01012的原因有多种, 官方文档给出的原因如下所示:

Cause
There is some environment setting issue .

Customer found that the issue is with creation password file .

The sporadic ORA-01012 error can be caused by several issues:

- A down database.

- Held memory segments from a previous instance crash. Use the ipcs command to find and remove the zombie RAM heap.

- File permissions in ORACLE_HOME have been changed while the database is running.

- An invalid value for the $ORACLE_SID environment variable.

- Exceeding the "processes" init.ora parameter (max sessions reached)

这个案例是Oracle异常崩溃(kill -9、断电、进程卡死,断开存储链路)时,没有自动释放共享内存 + 信号量,变成僵尸内存,新实例无法申请内存。也就是文中"Held memory segments from a previous instance crash. Use the ipcs command to find and remove the zombie RAM heap."这种情形.

一般出现这种情况,你可以使用下面命令查看,如果能看到一堆属于oracle 的内存/信号量,就是僵尸内存。

ipcs -m | grep oracle
ipcs -m | grep oracle

解决方案

解决方法非常简单, 使用shutdown abort命令释放这些僵尸内存(zombie RAM heap)后,就可以正常启动Oracle实例了.

shutdown abort;
startup