知识点参考:盖国强:《由浅入深oracle-DBA入门,进阶和诊断案例》
概念解释:
(Instance)实例:指一组后台进程(linux)/线程(windows)和一块(shared pool)共享内存区域.
数据库启动过程:
(1) 启动数据库到nomount状态;
(2) 启动数据库到mount状态;
(3) 启动数据库到open状态
一:nomount状态:
启动数据库的第一步,首先查找参数文件(pfile/spfile),根据参数文件中的配置创建实例进行内存区域的分配,启动后台进程(/线程)
由于在nomount状态,不需要控制文件,数据文件和日志文件的参与,因此,只需要参数文件就可以启动实例:
那么怎么检查数据库运行使用的是哪一个参数文件呢?往下看:
SQL> show parameter spfile
NAME TYPE VALUE
----------------------------------------------- ------------------------------
spfile string /u01/app/oracle/10.2.0/db01/db
s/spfileorcl.ora
若启动失败,我们从告警文件alert_$ORACLE_SID.ora中查找错误原因
告警文件路径:$ORACLE_HOME/admin/$ORACLE_SID/alert_$ORACLE_SID.ora
后台进程启动的顺序:
或者使用linux操作系统中的ps命令进行查看oracle后台进程:
[oracle@oracle bdump]$ ps -ef|grep ora_
oracle 6324 1 0 17:01 ? 00:00:00 ora_pmon_orcl
oracle 6326 1 0 17:01 ? 00:00:00 ora_psp0_orcl
oracle 6328 1 0 17:01 ? 00:00:00 ora_mman_orcl
oracle 6330 1 0 17:01 ? 00:00:00 ora_dbw0_orcl
oracle 6332 1 0 17:01 ? 00:00:00 ora_lgwr_orcl
oracle 6334 1 0 17:01 ? 00:00:00 ora_ckpt_orcl
oracle 6337 1 0 17:01 ? 00:00:00 ora_smon_orcl
oracle 6339 1 0 17:01 ? 00:00:00 ora_reco_orcl
oracle 6341 1 0 17:01 ? 00:00:00 ora_cjq0_orcl
oracle 6343 1 0 17:01 ? 00:00:00 ora_mmon_orcl
oracle 6345 1 0 17:01 ? 00:00:00 ora_mmnl_orcl
oracle 6535 5000 0 17:11 pts/2 00:00:00 grep ora_
实例启动时,首先查找spfile<sid>.ora;如果不存在,查找spfile.ora;如果依然不存在,查找pfile<sid>.ora,如果依然不存在,则实例无法启动。
一般情况下,在一个参数文件中只要有一个参数db_name就可以启动实例,以下为测试:
[oracle@oracle /]$ export ORACLE_SID=julia
[oracle@oracle /]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Productionon Fri Jun 7 17:59:00 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORA-01078: failure in processing systemparameters
LRM-00109: could not open parameter file'/u01/app/oracle/10.2.0/db01/dbs/initjulia.ora'
SQL> ! echo"db_name=julia">/$ORACLE_HOME/dbs/initjulia.ora
SQL> startup nomount
ORACLE instance started.
Total System Global Area 113246208 bytes
Fixed Size 1218004 bytes
Variable Size 58722860 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
在这种情况下,告警文件的路径也会有变化:
SQL> show parameter background_dump
NAME TYPE VALUE
----------------------------------------------- ------------------------------
background_dump_dest string /u01/app/oracle/10.2.0/db01/rd
bms/log
SQL> show parameter dump_dest
NAME TYPE VALUE
----------------------------------------------- ------------------------------
background_dump_dest string /u01/app/oracle/10.2.0/db01/rd
bms/log
core_dump_dest string /u01/app/oracle/10.2.0/db01/db
s
user_dump_dest string /u01/app/oracle/10.2.0/db01/rd
bms/log
SQL> show parameter control_files
NAME TYPE VALUE
----------------------------------------------- ------------------------------
control_files string /u01/app/oracle/10.2.0/db01/db
s/cntrljulia.dbf
当然,在进行rman操作时,如果没有参数文件依然可以启动实例。因为此时,数据库的db_name会被缺省为DUMMY;如下为测试:
[oracle@oracle dbs]$ exportORACLE_SID=meiyou
[oracle@oracle dbs]$ rman target/
Recovery Manager: Release 10.2.0.1.0 -Production on Fri Jun 7 18:12:36 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
startup failed: ORA-01078: failure inprocessing system parameters
LRM-00109: could not open parameter file'/u01/app/oracle/10.2.0/db01/dbs/initmeiyou.ora'
starting Oracle instance without parameterfile for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
RMAN> host;
[oracle@oracle dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Productionon Fri Jun 7 18:13:25 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise EditionRelease 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Miningoptions
SQL> show parameter db_name
NAME TYPE VALUE
----------------------------------------------- ------------------------------
db_name string DUMMY
查看告警文件dn_name的值:
$ cd /u01/app/oracle/10.2.0/db01/rdbms/log
[oracle@oracle log]$ cat alert_meiyou.log
System parameters with non-default values:
sga_target =159383552
compatible =10.2.0.1.0
_dummy_instance = TRUE
remote_login_passwordfile= EXCLUSIVE
db_name = DUMMY