Oracle启动实例分析

发表于:2017-3-01 09:59

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:answer_ma    来源:51Testing软件测试网采编

  1、nomout阶段,该阶段启动的前提是有参数文件,若没有参数文件,系统无法启动,在该过程中,系统分配内存、开启后台进程,同时更新alter日志文件
  实例nomount之前的状态:
  --无实例进程
  [oracle@secdb1 admin]$ echo $ORACLE_SID
  PROD
  [oracle@secdb1 admin]$ ps -ef|grep PROD
  oracle   14890  6310  0 21:12 pts/1    00:00:00 grep PROD
  --alter日志信息
  [oracle@secdb1 bdump]$ ls -lrt
  total 48
  -rw-r----- 1 oracle oinstall  1113 Mar  4 23:15 prod_lgwr_7319.trc
  -rw-r----- 1 oracle oinstall   779 Mar  5 19:42 prod_mmnl_7329.trc
  -rw-r--r-- 1 oracle oinstall 40910 Mar  5 21:08 alert_PROD.log
  此时启动实例到nomount状态
[oracle@secdb1 admin]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 5 21:15:50 2014
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area  314572800 bytes
Fixed Size                  1219184 bytes
Variable Size             100664720 bytes
Database Buffers          209715200 bytes
Redo Buffers                2973696 bytes
SQL>
  此时查看进程和日志信息
[oracle@secdb1 bdump]$ ls -lrt
total 52
-rw-r----- 1 oracle oinstall  1113 Mar  4 23:15 prod_lgwr_7319.trc
-rw-r----- 1 oracle oinstall   779 Mar  5 19:42 prod_mmnl_7329.trc
-rw-r--r-- 1 oracle oinstall 42513 Mar  5 21:15 alert_PROD.log  ----------------日志文件已经更新
[oracle@secdb1 bdump]$ ps -ef|grep PROD  ----------------------------系统中出现后台进程
oracle   14946     1  0 21:15 ?        00:00:00 ora_pmon_PROD
oracle   14948     1  0 21:15 ?        00:00:00 ora_psp0_PROD
oracle   14950     1  0 21:15 ?        00:00:00 ora_mman_PROD
oracle   14952     1  0 21:15 ?        00:00:00 ora_dbw0_PROD
oracle   14954     1  0 21:15 ?        00:00:00 ora_lgwr_PROD
oracle   14956     1  0 21:15 ?        00:00:00 ora_ckpt_PROD
oracle   14958     1  0 21:15 ?        00:00:00 ora_smon_PROD
oracle   14960     1  0 21:15 ?        00:00:00 ora_reco_PROD
oracle   14962     1  0 21:15 ?        00:00:00 ora_mmon_PROD
oracle   14964     1  0 21:15 ?        00:00:00 ora_mmnl_PROD
oracle   14965 14942  0 21:15 ?        00:00:00 oraclePROD (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle   14988  5989  0 21:17 pts/3    00:00:00 grep PROD
  如果在$ORACLE_HOME/dbs目录下无参数文件,启动实例是现象如下:
  [oracle@secdb1 dbs]$ sqlplus / as sysdba
  SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 5 21:21:19 2014
  Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  Connected to an idle instance.
  SQL> startup nomount
  ORA-01078: failure in processing system parameters
  LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initPROD.ora'
  SQL> quit
  参数寻找的优先级 spfileSID.ora----initSID.ora
  在该阶段,可以进行数据库的创建、控制文件的创建
  2、mount,在该阶段,启动条件是需要有控制文件,如果控制文件丢失或者损坏,启动将会报错。此时系统会打开控制文件、检查数据文件、日志文件的名称和位置,
  但此时不检查文件到底是否存在不存在
  mount之前:
SQL> select * from v$controlfile;
no rows selected
SQL> select * from v$datafile;
select * from v$datafile
*
ERROR at line 1:
ORA-01507: database not mounted
mount之后
SQL> alter database mount;
Database altered.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD/disk1/control01.ctl
/u01/app/oracle/oradata/PROD/disk2/control02.ctl
SQL> select file#,name from v$datafile;
FILE#  name
--------------------------------------------------------------------------------
1  /u01/app/oracle/oradata/PROD/disk1/system01.dbf
2  /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf
3 /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf
  在该阶段,可以进行数据库的完全恢复、修改数据库的归档模式、移动和重命令数据文件
SQL> archive log list  ---查看数据库归档模式
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/10.2.0/db_1/dbs/arch
Oldest online log sequence     3
Current log sequence           5
SQL> alter database archivelog; ---修改成归档模式
SQL> alter database noarchivelog;---修改成非归档模式
  如果控制文件丢失,系统报错,现象如下:
SQL> startup mount
ORACLE instance started.
Total System Global Area  314572800 bytes
Fixed Size                  1219184 bytes
Variable Size             100664720 bytes
Database Buffers          209715200 bytes
Redo Buffers                2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
  3、open阶段,该阶段主要是打开数据文件、日志文件,在打开的过程中对数据文件和日志文件进行一致性检查,如果不一致,则SMON进程继续实例恢复,如果文件丢失,打开失败。
SQL> alter database open;
Database altered.
--如何数据文件丢下,打开失败
SQL> startup mount;
ORACLE instance started.
Total System Global Area  314572800 bytes
Fixed Size                  1219184 bytes
Variable Size              79693200 bytes
Database Buffers          230686720 bytes
Redo Buffers                2973696 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/disk1/system01.dbf'
  4、小结
  启动时分成三个步骤,1、nomount阶段,该阶段是实例启动,根据参数文件进行系统分配内存,启动后台进程。mount阶段,根据控制文件来进行数据文件和日志文件的名称和位置检查,把实例和数据库连接起来。open阶段,就是数据库打开阶段,打开是就需要检查文件是否正常,有没有发生文件丢失或者不一致的情况,丢失则报错,不一致则进行实例恢复。
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号