Total Pageviews

Tuesday 1 May 2012

Oracle Database startup and shutdown


The instance and the database are separate entities and they can exist independently of each other. 

sqlplus /nolog
connect / as sysdba
startup nomount;  
alter database mount;
alter database open; 
connect  sys/oracle as sysdba;
·        
Nomonut:  The instance has been created in the memory (The SGA has been created and the background process started, according to whatever is specified in the parameter file.) but no connection has been made to the database. The only files used here are parameter file and alert log file. The parameters in the parameter file are used to build the SGA in the memory and to start the background processes. Entries will be written out to the alert log file describing this process. Alert log file is present at the location given by BACKGROUND_DUMP_DEST parameter of the parameter file. If the log already exists, it will be appended to otherwise, it will be created.
·         Mount: The database instance locates and reads the control file. Once the instance is successfully started in NOMOUNT mode, it may be transitioned to MOUNT mode by reading the control file. It locates the control file by using the CONTROL_FILES parameter. If the control file or any multiplexed copy of it is damaged database will not mount .All copies of control files must be available and identical if the mount is to be successful.
 As a part of mount, the names and locations of all the datafiles and online redo log files are read from the control file but oracle does not yet attempt to find them. This happens during the transition to OPEN mode. If any data file or redo log file are missing or damaged the database will remain in mount mode and cannot be opened until you take appropriate action. Furthermore even if all the files are present, they must be in synchronized before the database opens. If the last shutdown was orderly, with all database buffers in the DB buffer cache being flushed to disk by DBWn, then everything will be in synchronized. Oracle will know that all committed transactions are safely stored in the datafiles, and that no uncommitted transactions are hanging around waiting to be roll backed. However if the last shutdown was disorderly, then oracle must repair the damage. The process that mounts and  and open the database is SMON.
·         OPEN: All database files are located and opened and the database is made available for use by the end users.

Oracle Shutdown database:  During an orderly shutdown  , the database is first closed and then demounted and finally the instance is stopped. During the close phase, all sessions are terminated and rolled back by PMON ,completed transactions are flushed to the disk by DBWn,and the datafiles and redo log files are closed. During the dismount, the control file is closed. Then the instance is stopped by deallocating the SGA and terminating the background processes.
Sqlplus /nolog
Connect  / as sysdba
Shutdown  [Normal/immediate/Abort/Transactional]
Shutdown Normal
This is the default .No new user connections will be permitted, but all current connections are allowed to continue. Only once all users have logged off will the database actually shut down.
Shutdown Transactional
No new user connections are permitted; existing sessions that are not in a transaction will be terminated; sessions currently in a transaction are allowed to complete the transaction and will be terminated. Once all sessions are terminated ,the database will shut down.
Shutdown Immediate
Perhaps the best way to initially shutdown the database is the shutdown immediate command. This command will prevent any new logins, then rollback any uncommitted transactions, and then bring down the database. In the process of bringing down the database, Oracle will flush all the changes in memory out to the database datafiles too, just like a regular shutdown does. This makes database startup quicker.
The shutdown immediate command will work most of the time, but there are times when it can hang and fail to shutdown the database. In these cases, the shutdown abort command is called for.
Shutdown Abort
The shutdown abort command is pretty much a guaranteed way to get your database to shutdown. It’s a “hard crash” of the database, and this can result in a longer time to start the database back up.
A shutdown abort should not be your first shutdown method of choice, there may be times when you must force the database down

No comments:

Post a Comment