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