Oracle Database : Startup basics (How to start Oracle Database) And Shutdown Basics (How to Shutdown Oracle Database)
Oracle Database: Startup basics (How to start Oracle Database)
And
Shutdown Basics (How to Shutdown Oracle Database)
Startup basics (How to start Oracle Database)
Oracle Database and Instance :
Database startup :
The above syntax assumes you have a pfile or spfile in the default location ($ORACLE_HOME/dbs). If you are using a non-default parameter file, the startup command is:
$ sqlplus / as sysdba
SQL> startup pfile=[file name and location]
Nomount stage :
Mount stage :
$ sqlplus / as sysdba
SQL> startup mount
To mount a database from nomount stage:
$ sqlplus / as sysdba
SQL> alter database mount
Open stage :
– This is the final stage and here Oracle opens the online datafiles and redolog files.– If any of the required files are not present, media recovery is required .– It also ensures the datafiles are consistent. Incase of a normal shutdown,the in-memory changes will be written to disk as part of the shutdown checkpoint.– But if the instance crashed (or shutdown abort), then Oracle Database performsthe instance recovery in the next startup.To open a database :$ sqlplus / as sysdbaSQL> startup
To open a database from mount stage:$ sqlplus / as sysdba
SQL> alter database open
To verify :SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE
Shutdown Basics (How to Shutdown Oracle Database)Oracle Database and Instance :
The Database is a set of physical operating system files. These files actually holds the user data and the metadata (or the data dictionary). Every running Oracle database is associated with (atleast) an Oracle instance.The Instance refers to the set of Oracle background processes or threads and a shared memory area (SGA). An instance can mount and open at most one database in its life.A database may be mounted and opened by one or more instances (using RAC) and the number of instances mounting a single database can fluctuate over time.Database Shutdown :
During a database shutdown we close the database and terminates the instance.
Different Modes in Database Shutdow
There are different modes to bring down the database:
1. Shutdown immediate
2. Shutdown transactional
3. Shutdown normal
4. Shutdown abortNo user session will be permitted once you issue any of these Shutdown commands.
Shutdown Immediate :
– Oracle Database terminates any executing SQL statements and disconnects users.– Active transactions are terminated and uncommitted changes are rolled back.– Oracle then performs a checkpoint and then close the online datafiles.$ sqlplus / as sysdba
SQL> shutdown immediate
Shutdown Transactional :
– This mode prevents users from starting new transactions, but waits for all current transactions to complete before shutting down.
– Oracle then performs a checkpoint and then close the online datafiles.
$ sqlplus / as sysdba
SQL> shutdown transactional
Shutdown Normal :
– The database waits for all connected users to disconnect before shutting down.– It waits till all the current transactions end.– Oracle then performs a checkpoint and then close the online datafiles.$ sqlplus / as sysdba
SQL> shutdown abort
Different Phases in Database Shutdown :
Close the Database :
– Oracle writes the data in the SGA to the disk, updates the file headers and closes the onlinedatafiles and the redo log files.– But the database will still be mounted.Dismount the Database :
– After the database is closed, Oracle Database unmounts the database to disassociate it fromthe instance.– After a database is unmounted, Oracle Database closes the control files of the database.– At this point, the instance remains in memory.Shutdown the Instance :
The last step is to remove the shared memory (SGA) and terminate the background processes. Sometimes shutdown does not cleanup the SGA or background process completely. This can cause error during the next startup. In such situation we can force a instance startup.
Comments
Post a Comment