錯誤場景:
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!