Sunday 18 October 2015

Starting up the Oracle Database

We left off at ps -ef | grep LOCAL in the last post. This command is used during shutdown to kill OS processes in view of making the process faster. But as the topic suggests we are only going to explain startup here because I won't be able to discuss each topic at length if I put both of them in a single post... so you can guess what the next post will be about. Starting up the database might seem like a trivial topic for non-production DBAs which is quite understandable because the actual command is just startup [forcce/mount/nomount] but believe me there's more to it.

Before deep diving into today's topic, I'm gonna chip in a little fact about most DBAs or IT Professionals... most of the terms we use are not the actual/real technical term. A good example is our topic for today - you don't actually shutdown or startup a database... it's the instance that is started/shutdown. If we look at it critically, Oracle defines "the database" as a set of files on disk - by design these can't be started or shutdown. It also call's it's RDBMS Software "Database Nx" - where N is version number and x represents the flagship feature of that version e.g. Database 12c, Database 11g and so on... this can be a little confusing but what's paramount is to be able to make the distinction between instance, database files, Oracle - the software and Oracle Corporation - the company when situation warrants it.

The Instance is a set of memory structures and background processes that manages database files. When an instance is started, Oracle allocates a memory area called the System Global Area (SGA) and starts some background processes. 

The Database is a set of files on disk which data is stored and retrieved. Files that make up the database in Oracle are the data files, redo logfiles and control files. These files are occasionally loaded into memory for various forms of processing.

Starting the Instance
The mode of instance startup determines the state of the database. When the instance is started the database becomes available for valid users to connect. The database can be started up in either of the three modes listed below;

Nomount
SQL>startup nomount;

Mount
SQL>startup nomount;

Open
SQL>startup; | startup mount; / alter database open;


You can also startup the database using specific parameters by creating a parameter file and using same to startup the database. By default a parameter file is read from the location %ORACLE_HOME%\database (Windows) or $ORACLE_HOME/dbs (UNIX). In the default location for each platform Oracle locates the initialization parameter file by examining file names in the following order:
  1. spfile$ORACLE_SID.ora
  2. spfile.ora
  3. init$ORACLE_SID.ora

To explicitly specify a non default initialization parameter file use the command;


SQL> startup [nomount|mount] pfile= '/any_location/pfile.ora';

Stages of database startup
When a startup command is issued, the database will read the initialization parameter file(init.ora). Oracle uses this to determine the applicable configurations, Oracle then acquires memory area for its SGA and some background processes are started. When these have been done successfully the database is said to be in NOMOUNT state at this point. Oracle then moves to read the controlfile (a binary file that keeps information about the physical structure of the database) and accesses all the database files. At this point the database is MOUNTED. After mount state the database moves to OPEN state after reading the data files and other files associated with the database. Some processes like the ARC, RECO are also started here.

It is very important for DBAs to have an in depth understanding of the various startup modes because several situations like Database Recovery, Upgrades or changing updating static parameter might require you to put the database in any of the startup modes. Visit http://docs.oracle.com for more on starting the database instance.


Hope this helps!

Kehinde.

3 comments: