数据库无法启动ORA-01034: ORACLE not available
错误场景:
1、数据库未启动,查询v$instance报错
1 SQL> select status from v$instance; 2 select status from v$instance 3 * 4 ERROR at line 1: 5 ORA-01034: ORACLE not available 6 Process ID: 0 7 Session ID: 0 Serial number: 0
v$instance视图都不能查询(该视图在nomount状态即可查询),意味着数据库没启动
2、启动数据库报错
1 SQL> startup nomount; 2 ORA-01078: failure in processing system parameters 3 LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initdg_standby.ora'
报错找不到参数文件initdg_standby.ora,意味着找不到spfile,在参数文件目录查看:
1 [oracle@zml-rhel6 ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/ 2 [oracle@zml-rhel6 dbs]$ ll 3 total 32 4 -rw-rw---- 1 oracle oinstall 1544 Dec 22 15:53 hc_DBUA0.dat 5 -rw-rw---- 1 oracle oinstall 1544 Dec 22 15:55 hc_dg01.dat 6 -rw-rw---- 1 oracle oinstall 1544 Dec 22 16:10 hc_test.dat 7 -rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora 8 -rw-r----- 1 oracle oinstall 24 Dec 22 15:54 lkDG_01 9 -rw-r----- 1 oracle oinstall 1536 Dec 22 15:55 orapwdg01 10 -rw-r----- 1 oracle oinstall 2560 Feb 4 10:05 spfiledg01.ora 11 -rw-r----- 1 oracle oinstall 3584 Dec 22 16:10 spfiletest.ora 12 [oracle@zml-rhel6 dbs]$
可以看到该目录下有两个参数文件,sid分别为dg01,test,应该是环境变量ORACLE_SID设置的有问题
3、查看环境变量ORACLE_SID
1 [oracle@zml-rhel6 ~]$ cat .bash_profile 2 # .bash_profile 3 4 # Get the aliases and functions 5 if [ -f ~/.bashrc ]; then 6 . ~/.bashrc 7 fi 8 9 # User specific environment and startup programs 10 unset DISPLAY 11 PATH=$PATH:$HOME/bin 12 13 export PATH 14 umask 022 15 16 export TMP=/u01/app/tmp 17 export TMPDIR=/u01/app/tmp 18 export ORACLE_BASE=/u01/app/oracle 19 export ORACLE_SID=dg_standby 20 export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 21 export PATH=$ORACLE_HOME/bin:$PATH 22 export LD_LIBRARY_PATH=$ORACLE_HOME/lib
环境变量中的ORACLE_SID为dg_standby,应该是静默安装时部分参数含义未弄清楚导致设置错误
解决
1、修改ORACLE_SID环境变量为dg01
export ORACLE_SID=dg01
source .bash_profile
2、启动数据库
1 SQL> startup open 2 ORACLE instance started. 3 4 Total System Global Area 1603411968 bytes 5 Fixed Size 2213776 bytes 6 Variable Size 989857904 bytes 7 Database Buffers 603979776 bytes 8 Redo Buffers 7360512 bytes 9 Database mounted. 10 Database opened.
over!