Thursday, June 17, 2010

Oracle Server Architecture


Primary components:
1)      Oracle server: Consists of Oracle Instance and oracle physical file structure that we will discuss next.
2)      Oracle Instance: Consists of the background processes and memory structures.
 When you connect to any database it allocates a memory area called System Global Area (SGA).
And mandatory background process PMON, SMON, DBWR, LGWR, CKPT also starts. Background process performs automatic read/write operations from physical file to SGA component & vice versa and managing memory. Thus one instance can connect to only one database.
3)      Oracle Database : Consists of files organization required for physical storage of data, backup files of database and other information required at the time of recovery in case of instance failure.
Following types of physical file present.
  •       Pfile :  parameter file is a text file contains initialization parameters needed to startup database.
  •       Spfile:  server parameter file it is a binary file containing  initialization parameters needed to startup database.
  •       Control file:  contains information about physical location of other files.
  •       Redo log file: contains log entries of each activities in database. Used for recovery of database.
  •       Archive log file: it is back up of redo log files when redo log files are full.
  •       Data file: Actual schema and data is stored here.
  •       Alert log files: Text file where all major database activities are recorded with timestamp.
  •       Trace log files: contains the details of error generated from system, server or by users.
  •       Password file:  Specifies the authentication of database users.

File type
Extension
Default  location (when created with OMF)
Pfile :
ORA
C:\oracle\product\10.2.0\admin\orcl\pfile
Spfile:
ORA
C:\oracle\product\10.2.0\db_1\database
Control file:  
CTL
C:\oracle\product\10.2.0\oradata\orcl
Redo log file:
LOG
C:\oracle\product\10.2.0\oradata\orcl
Archive log file:
LOG
C:\oracle\product\10.2.0\flash_recovery_area\ORCL\ARCHIVELOG
Data file:
DBF
C:\oracle\product\10.2.0\oradata\orcl
Alert log files:
LOG
C:\oracle\product\10.2.0\admin\orcl\adump
Trace log files:
TRC
C:\oracle\product\10.2.0\admin\orcl\udump|bdump|cdump
Password file: 
ORA
C:\oracle\product\10.2.0\db_1\database
 
In my next post I will discuss use of all SGA components shown in figure and roles of all the background processes.

Wednesday, June 16, 2010

Startup and ShutDown of Database

Whenever an Oracle database is started, it goes through a series of steps to ensure database
consistency. When it starts up, a database passes through three modes: NOMOUNT, MOUNT, and OPEN. We will review each of these modes and a few other special startup options and discuss when you need to use these options. Following commands are used for startup and shutdown options.


Before going through this post i recommend you to read my this this post first.



·         STARTUP NOMOUNT
When a database is started in this mode, the parameter file is read and the background processes and memory structures are initiated, but they are not attached or communicating with the disk structures of the database. When the instance is in this state, the database is not available for use.
In this mode, you can perform tasks such as run a script that creates the underlying database.
At times, a database may not be able to go to the next mode (called MOUNT mode) and remains in NOMOUNT mode. For example, this can occur if Oracle has a problem accessing the control file structures, which contain important information to continue with the startup process.
If these structures are damaged or not available, the database startup process cannot continue until the problem is resolved.

·         STARTUP MOUNT
In this mode attaches and interacts with the database structures. At this point, Oracle reads the control files that it uses to locate and attach to the main database structures.
Certain administrative tasks can be performed while the database is in this mode, for example, recovery. You can also physically change file locations or place the database in archive log mode.

·         STARTUP OPEN  (default)
This option is the default startup mode if no mode is specified. It performs all the steps of the STARTUP NOMOUNT and STARTUP MOUNT options. This option makes the database available to all users.

Other startup options

·         STARTUP FORCE
This is used if you are experiencing difficulty in starting the database in a normal fashion. For example, if a database server lost power and the database stopped abruptly, it can leave the database in a state in which a STARTUP FORCE startup is necessary. What is also different about STARTUP FORCE is that it can issued no matter what mode the database is in. STARTUP FORCE does a shutdown abort(discusse below) and then restarts the database.

·         STARTUP RESTRICT
This mode opens the database, but gives access only to users who have the RESTRICTED SESSION privilege. You might want to open a database using the RESTRICTED option when you want to perform maintenance on the database while it is open but ensure that users cannot connect and perform work on the database. You might also want to open the database using the RESTRICTED option to perform database exports or imports and guarantee that no users are accessing the system during these activities. After you are done with your work, you can disable the restricted session, ALTER SYSTEM DISABLE RESTRICTED SESSION, so everyone can connect to the database.

·         SHUTDOWN NORMAL (default)
A normal shutdown is the default type of shutdown that Oracle performs if no shutdown
options are provided. Following things happens when doing a normal shutdown:
  • No new Oracle connections are allowed from the time the SHUTDOWN NORMAL command is issued.
  • The database will wait until all users are disconnected to proceed with the shutdown process.
Because Oracle waits until all users are disconnected before shutting down, you can find
yourself waiting indefinitely for a client who may be connected but is no longer doing any work or may have left for the day. This can require extra work, identifying which connections are still active and either notifying the users to disconnect or forcing the client disconnections by killing their session. This type of shutdown is also known as a “clean” shutdown because when you start Oracle again, no recovery is necessary.

·         SHUTDOWN TRANSACTIONAL
This is a bit more aggressive than a normal shutdown. The characteristics of the transactional shutdown are as follows:
  • No new transactions are allowed to start from the time the SHUTDOWN TRANSACTIONAL command is issued.
  • Once all active transactions on the database have completed, all client connections are
disconnected.
A transactional shutdown does allow client processes to complete prior to the disconnection.
This can prevent a client from losing work and can be valuable especially if the database has
long-running transactions that need to be completed prior to shutdown. This type of shutdown
is also a clean shutdown and does not require any recovery on a subsequent startup.

·         SHUTDOWN IMMEDIATE
The immediate shutdown method is the next most aggressive option. An immediate shutdown
is characterized as follows:
  • No new Oracle connections are allowed from the time the SHUTDOWN IMMEDIATE command is issued.
  • Any uncommitted transactions are rolled back. Thus, a user in the middle of a transaction

  • will lose all the uncommitted work.
Oracle does not wait for clients to disconnect. Any unfinished transactions are rolled back,
and their database connections are terminated.
This type of shutdown works well if you want to perform unattended or scripted shutdowns
of the database and you need to ensure that the database will shut down without getting hung
up during the process by clients who are connected. Even though Oracle is forcing transactions to roll back and disconnecting users, an immediate shutdown is still considered a clean shutdown.
No recovery activity takes place when Oracle is subsequently restarted.

·         SHUTDOWN ABORT
A shutdown abort is the most aggressive type of shutdown and has the following characteristics:

  • No new Oracle connections are allowed from the time the SHUTDOWN ABORT command is issued.
  • Any SQL statements currently in progress are terminated, regardless of their state.
  • Uncommitted work is not rolled back.
  • Oracle disconnects all client connections immediately upon the issuance of the this command.

Do not use SHUTDOWN ABORT regularly. Use it only if the other options for database shutdown fail This type of shutdown is not a clean shutdown and requires recovery when the database is subsequently started.