OracleWhen the database instance is started, it is divided into three stages: nomount, mount and open. The following example analysis shows what the system does at different stages.
1. Nomout stage. The prerequisite for starting this stage is that there is a parameter file. If there is no parameter file, the system cannot start. During this process, the system allocates memory, opens the background process, and updates the alter log file.
The status before the instance nomount:
--No instance process
[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 log information
[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
At this time, start the instance to the nomount state
[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>
Check the process and log information
[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
If there is no parameter file in the $ORACLE_HOME/dbs directory, the startup instance is as follows:
[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/'
SQL> quit
Priority for parameter search
At this stage, you can create databases and control files.
2. mount. At this stage, the startup condition is that there is a control file. If the control file is lost or corrupted, an error will be reported in the startup. At this time, the system will open the control file, check the name and location of the data file, and log file.
But at this time, do not check whether the file exists or not.
Before 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
After mount
SQL> alter database mount;
Database altered.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD/disk1/
/u01/app/oracle/oradata/PROD/disk2/
SQL> select file#,name from v$datafile;
FILE# name
--------------------------------------------------------------------------------
1 /u01/app/oracle/oradata/PROD/disk1/
2 /u01/app/oracle/oradata/PROD/disk1/
3 /u01/app/oracle/oradata/PROD/disk1/
At this stage, you can complete the database recovery, modify the database archive mode, move and re-command the data file
SQL> archive log list --View database archive mode
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; ---Modify into archive mode
SQL> alter database noarchivelog;---Modify into non-archive mode
If the control file is lost, the system reports an error, and the phenomenon is as follows:
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 stage, this stage mainly opens data files and log files, and performs consistency checks on the data files and log files during the opening process. If they are inconsistent, the SMON process will continue to recover the instance. If the file is lost, the opening fails.
SQL> alter database open;
Database altered.
--How to drop the data file and fail to open it
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/'
4. Summary
It is divided into three steps when starting, 1. The nomount stage, which is the instance startup, and the system allocates memory according to the parameter file, and starts the background process. In the mount stage, the name and location of data files and log files are checked according to the control file, and the instance and database are connected. The open stage is the database opening stage. When opening, you need to check whether the file is normal and whether there are any files lost or inconsistent. If there is an error, it will be reported. If there is an inconsistent, it will be restored.
jiangkch
20140305
---------------------------------------------
From "ITPUB Blog", link: /393784/viewspace-1101878/. If you need to reprint, please indicate the source, otherwise legal responsibility will be pursued.