有同事问我,他的数据库启动失败,报错如下:
ORA-00205: error in identifying control file, check alert log for more info
这种报错,立刻可以想到的是,控制文件损坏,或者控制文件不存在
我查看了控制文件是存在的,但是控制文件的路径有点奇怪,一个在
/home/oracle/product/oradata/orcl/control01.ctl
另外一个在闪回目录下
于是我创建了一个pfile /home/oracle/zhu.ora
然后修改了里/home/oracle/zhu.ora关于控制文件的指定,只指定一个控制文件,如下
*.control_files='/home/oracle/product/oradata/orcl/control01.ctl'
再尝试启动数据库
SQL>startup pfile='/home/oracle/zhu.ora'
依然报错ORA-00205: error in identifying control file, check alert log for more info
此时我查看了alert文件,发现如下报错信息
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/home/oracle/product/oradata/orcl/control01.ctl'
ORA-27086: unable to lock file - already in use
这个表示控制文件已经被人打开了,我没法再次打开了。
于是 ps -ef | grep oracle 发现很多oracle的进程
oracle 2233 1 0 21:03 ? 00:00:00 ora_pmon_ora11g
oracle 2235 1 0 21:03 ? 00:00:00 ora_psp0_ora11g
oracle 2237 1 0 21:03 ? 00:00:00 ora_vktm_ora11g
oracle 2241 1 0 21:03 ? 00:00:00 ora_gen0_ora11g
oracle 2243 1 0 21:03 ? 00:00:00 ora_diag_ora11g
oracle 2245 1 0 21:03 ? 00:00:00 ora_dbrm_ora11g
oracle 2247 1 0 21:03 ? 00:00:00 ora_dia0_ora11g
oracle 2249 1 0 21:03 ? 00:00:00 ora_mman_ora11g
oracle 2251 1 1 21:03 ? 00:00:01 ora_dbw0_ora11g
这时我怀疑可能是rc.local设置了开机自动
果然
[oracle@V-02-01-00410 etc]$ more /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'
于是我将rc.loca里的开机自动启动oracle的功能注释掉了
然后reboot
好了,我这个时候再用zhu.ora启动数据库就OK了
SQL> startup pfile='/home/oracle/zhu.ora'
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2253664 bytes
Variable Size 1006636192 bytes
Database Buffers 587202560 bytes
Redo Buffers 7319552 bytes
Database mounted.
Database opened.
然后我再次关闭数据库,做了如下操作
到/home/oracle/product/oradata/orcl/目录下复制两份控制文件
cp control01.ctl control02.ctl
cp control01.ctl control03.ctl
修改/home/oracle/zhu.ora里面控制文件的说明,增加两个控制文件
*.control_files='/home/oracle/product/oradata/orcl/control01.ctl','/home/oracle/product/oradata/orcl/control02.ctl','/home/oracle/product/oradata/orcl/control03.ctl'
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup pfile='/home/oracle/zhu.ora'
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2253664 bytes
Variable Size 1006636192 bytes
Database Buffers 587202560 bytes
Redo Buffers 7319552 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='/home/oracle/zhu.ora';
File created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2253664 bytes
Variable Size 1006636192 bytes
Database Buffers 587202560 bytes
Redo Buffers 7319552 bytes
Database mounted.
Database opened.
此时数据库已经能用spfile正常启动了