Posts Tagged ‘Oracle DBA’

Table That Stores Cached Queries

November 14th, 2018, posted in Oracle Queries
Share

This error is caused by corruptions that have crept into a table that stores cached queries. The only thing to do in this situation is to delete that table and clear cache by bouncing the Apache server.

There is patch available that can reduce the chance of these corruptions from happening in the future.

Please do the following

CREATE TABLE fnd_lov_choice_values_bak AS
SELECT * FROM fnd_lov_choice_values
;

DELETE fnd_lov_choice_values;

COMMIT;

Clear the cache

Then bounce the Apache server.

Then please download and apply patch Patch:9527712:R12.FWK.B

Afterwords, please try you test again.

Share

RMAN-08137: WARNING: archived log not deleted, needed for standby

November 6th, 2018, posted in Oracle Queries
Share

Recently I met with an Oracle error “RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process” while deleting the archived logs through RMAN prompt.
I simulated the same on my test machine.Note. I had configured standby for my primary database but not the upstream.Followings are the excerpts from the RMAN output.

RMAN> delete noprompt archivelog all;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/admin/db1/arch/1_146_812203684.dbf thread=1 sequence=146
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/admin/db1/arch/1_147_812203684.dbf thread=1 sequence=147
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/admin/db1/arch/1_148_812203684.dbf thread=1 sequence=148
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/admin/db1/arch/1_149_812203684.dbf thread=1 sequence=149

 

I could delete those archivelogs using “force” option as well.
RMAN > delete noprompt force archivelog all;

 

But I dont want to do the same as those archivelogs have not shipped yet to the standby server.
So I changed the rman configuration to do the same.
RMAN> show all;

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default


RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;

new RMAN configuration parameters:

CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;

new RMAN configuration parameters are successfully stored

RMAN-08591: WARNING: invalid archived log deletion policy
RMAN> show all;

CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;

 

Now I was able to delete those archivelogs.
RMAN> delete noprompt archivelog all;




released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=147 device type=DISK

List of Archived Log Copies for database with db_unique_name DB1

=====================================================================




Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

239     1    146     A 24-MAY-13

        Name: /u01/app/oracle/admin/db1/arch/1_146_812203684.dbf




247     1    147     A 24-MAY-13

        Name: /u01/app/oracle/admin/db1/arch/1_147_812203684.dbf




249     1    148     A 24-MAY-13

        Name: /u01/app/oracle/admin/db1/arch/1_148_812203684.dbf




250     1    149     A 24-MAY-13
        Name: /u01/app/oracle/admin/db1/arch/1_149_812203684.dbf

..........

..........

deleted archived log

archived log file name=/u01/app/oracle/admin/db1/arch/1_146_812203684.dbf RECID=239 STAMP=816273514

deleted archived log

.........

………

RMAN> crosscheck archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=147 device type=DISK
specification does not match any archived log in the repository

 

Once I deleted those logs, I changed the rman configuration by the default one.
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY CLEAR;

 

old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;

 

RMAN configuration parameters are successfully reset to default value
Share

RMAN-06059: expected archived log not found, loss of archived log compromises recoverability

November 4th, 2018, posted in Oracle Queries
Share

While RMAN full backup, today i have encountered “RMAN-06059: expected archived log not found, loss of archived log compromises recoverability”

RMAN error.
Solution for the mentioned error is to Crosscheck your archive logs from RMAN prompt and delete those expired logs who are not needed anymore.

While crosscheck archivelogs, RMAN will marked archives as Expired in his repository (i.e. controlfile or catalog) those who are not physically present there. So we can easily delete expired archives from controlfile or catalog repository.

 

Error log 1 :

RMAN> RUN
 2> {
 3> ALLOCATE CHANNEL backup1 DEVICE TYPE DISK FORMAT 'Z:\RMAN\%U';
 4> BACKUP DATABASE PLUS ARCHIVELOG;
 5> }
using target database control file instead of recovery catalog
 allocated channel: backup1
 channel backup1: SID=70 device type=DISK
Starting backup at 10-SEP-14
 current log archived
 released channel: backup1
 RMAN-00571: ===========================================================
 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
 RMAN-00571: ===========================================================
 RMAN-03002: failure of backup plus archivelog command at 09/10/2014 18:22:35
 RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
 ORA-19625: error identifying file E:\ORACLE\--ORACLE_SID--\ORAARCH\1_35338_778192583.DBF
 ORA-27041: unable to open file
 OSD-04002: unable to open file
 O/S-Error: (OS 2) The system cannot find the file specified.

Error log 2 :

Starting backup at 26-JUL-12
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 07/26/2012 22:55:32
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /app/oracle/product/10.2/dbs/arch1_1_781981525.dbf
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3


Cause:

This can happen for a variety of reasons; the file has been manually moved or deleted,
the archive log destination has recently been changed,
the file has been compressed, etc

Solution:

Your options are either to restore the missing file(s), or to perform a crosscheck.
To perform a crosscheck, run the following command from within RMAN:

RMAN> CROSSCHECK ARCHIVELOG ALL;

Above command will give information of expired RMAN repository after verification. (i.e. in catalog or controlfile)

Above will marked archives as Expired who are not available physically and who are not required for any kind of recovery.

RMAN> DELETE EXPIRED ARCHIVELOG ALL;

Above command will delete all archive logs who are marked as expired while crosscheck.

 

Enabling And Checking the Status of Flashback On Database,Oracle Database,Oracle DBA,Enabling Flashback On Database,Checking the Status of Flashback On Database, Status of Flashback On Database, Enable Flashback On Database, Enabling Flashback On Database,Enable Flashback On Oracle Database, Enabling Flashback On Oracle Database,ORA-01153: an incompatible media recovery is active,ORA-01153,Oracle Error,Ora Error,Oracle DBA,Oracle Database Error,Oracle Database Solution,an incompatible media recovery is active,Ora : an incompatible media recovery is active,Oracle an incompatible media recovery is active,Oracle Error Solution,Database DBA,oracle data guard,oracle data guard issues,oracle data guard error

Details :

What? When using RMAN to backup archivelog files, an error “RMAN-06059: Errror identifying file ” is returned. Prior to this the backups have been running successfully.

RMAN-03002: failure of backup plus archivelog command
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
RMAN-6059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625 “error identifying file %s”

Why? Oracle is trying to backup an archivelog and is expecting for it to be available as it could be required for recovery.

Cause: The archive log is no longer accessible. One of the common reasons is that the archive log has been removed manually to free up space on the system or the permissions on the file was changed.

Resolution: The most important thing is to determine what caused the file to not be available.

Then to get around this error, to allow RMAN to continue backing up the database first connect to the RMAN repository. The run the “CROSSCHECK ARCHIVELOG ALL”.

RMAN will continue to backup the rest of the archivelogs.

Caution: Ensure that you also take a full backup since one f the archivelogs is not available in the backupsets and will limit your ability to do a complete recovery without it.

Share

Oracle Database : How to Backup Oracle Database using RMAN with Examples

October 28th, 2018, posted in Oracle Queries
Share

Even if you are not an Oracle DBA, you’ll still encounter a situation where you may have to take a backup of an Oracle database.

Using Oracle RMAN, you can take a hot backup for your database, which will take a consistent backup even when your DB is up and running.

This tutorial gives you an introduction on how to perform Oracle DB backup using RMAN.

For the impatient, here is the quick snippet, that takes RMAN backup of both database and archive logs.

RMAN> BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;

Oracle Database : How to Backup Oracle Database using RMAN with Examples,Oracle Database,How to Backup Oracle Database, using RMAN with Examples,How to Backup Oracle,Oracle,Database,Oracle Database DBA,Oracle DBA,Database DBA,Oracle Database using RMAN,RMAN Oracle Database ,Oracle Database RMAN,Backup Oracle Database,Backup,Oracle Backup

1. View Current RMAN Configuration

Before we take the backup, we have to configure certain RMAN parameters. For example, how long you want to reatain the RMAN backup, etc.

Before we modify any configuration, execute the following command to view all current RMAN configuration settings.

To connect to RMAN, do the following from command line. This will take you to RMAN> command prompt, from here you can execute all RMAN commands.

$ rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Sat Aug 10 11:21:29 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: DEVDB (DBID=821773)
RMAN>

To view current RMAN configurations, execute “show all”.

RMAN> SHOW ALL;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO "/backup/rman/ctl_%F";
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 2;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   "/backup/rman/full_%u_%s_%p" MAXPIECESIZE 2048 M;
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/dbs/snapcf_devdb.f'; # default

As you see above, it displays various RMAN parameters and their current values.

2. Change Few RMAN Configuration Parameters

Location: One of the important configuration parameters to set will be, where you want to save the RMAN backup. In the following example, I’m settting the RMAN backup loacation as “/backup/rman/”

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backup/rman/full_%u_%s_%p';

Retention Period: Next, you should specify how long you want to retain the backup for. When RMAN takes a backup, it automatically deletes all the old backups that are older than the retention period. In the following example, I’m setting the retention period as 7 days, which will keep the DB backup for a week.

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

Verify that the above two changes are done.

RMAN> SHOW ALL;
..
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/backup/rman/full_%u_%s_%p';
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
..

Clear a Parameter: If you want to clear a parameter and set its value to default, use CLEAR at the end of the configuration as shown below.

RMAN> CONFIGURE RETENTION POLICY CLEAR;

In this example, since we cleared the retention policy’s value, it was set to the default value, which is 1. So, the retention policy is set to 1 day as shown below.

RMAN> SHOW ALL;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

 

3. Backup Oracle Database

Make sure the directory mentioned in the CHANNEK DEVICE TYPE DISK FORMAT is created. i.e /backup/rman/

$ mkdir -p /backup/rman

Currently this directory is empty. We’ll see what this has after the backup is taken.

$ ls -l /backup/rman
total 0

We can take a backup using image copy or in backup set. It is strongly recommended to use RMAN backup sets to backup the database.

RMAN stores the backup in backup sets, which are nothing but whole bunch of files which contains the backed-up data. Only RMAN understands the format of these files. So, if you backup an Oracle DB using RMAN, only RMAN knows how to read the backup and restore it.

Typically we’ll use “BACKUP AS BACKUPSET” to backup a database. So, to take a full backup of the database without the archive logs, do the following.

RMAN> BACKUP AS BACKUPSET DATABASE

To take a full backup of the database with the archive logs, do the following:

RMAN> BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;

You can also take a backup of only a specific table space. The following example takes backup of only PRD01 tablespace.

RMAN> BACKUP AS BACKUPSET TABLESPACE PRD01;

The RMAN backup output will be something similar to the following:

RMAN> BACKUP AS BACKUPSET DATABASE
Starting backup at 10-AUG-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=193 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=192 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00025 name=/u03/oradata/devdb/devuser07.dbf
input datafile fno=00003 name=/u02/oradata/devdb/temp01.dbf
channel ORA_DISK_1: starting piece 1 at 10-AUG-13
channel ORA_DISK_2: starting full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00008 name=/u03/oradata/devdb/devusers05.dbf
channel ORA_DISK_2: starting piece 1 at 10-AUG-13
...
..

piece handle=/backup/rman/full_4dogpd0u_4237_1 tag=TAG20130808T114846 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 10-AUG-13
...
Starting Control File and SPFILE Autobackup at 10-AUG-13
piece handle=/backup/rman/ctl_c-758818131-20130808-00 comment=NONE
Finished Control File and SPFILE Autobackup at 10-AUG-13

Once the backup is completed, do an ls on the /backup/rman directory, you’ll now see RMAN backup files.

$ ls -l /backup/rman
total 14588
-rw-r----- 1 oracle dba 14585856 Aug  8 11:48 ctl_c-758818131-20130808-00
-rw-r----- 1 oracle dba   327680 Aug  8 11:48 full_4dogpd0u_4237_1

Note: Once a backup is taken, to view all available database backups from RMAN, you need to use “list” command that is shown further down in one of the examples.

While this may be obvious, it is worth repeating again: Since we are taking hotbackup, the Oracle database can be up and running. Make sure your Oracle database is running before you execute any of the above RMAN backup commands.

4. Assign Backup TAG Name for Quick Identification

If you are taking lot of backups, it will be easier to assign a tag to a particular backup, which we’ll later use during Oracle recovery (or while using list command to view it).

The following example assign a backup tag called “WEEEKLY_PRD01_TBLS_BK_ONLY” to this particular backup.

RMAN> BACKUP AS BACKUPSET TAG 'WEEEKLY_PRD01_TBLS_BK_ONLY' TABLESPACE PRD01;
Starting backup at 10-AUG-13
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00002 name=/u03/oradata/devdb/PRD01_1.dbf
channel ORA_DISK_1: starting piece 1 at 10-AUG-13
channel ORA_DISK_1: finished piece 1 at 10-AUG-13
piece handle=/backup/rman/full_4fogpdb3_4239_1 tag=WEEEKLY_PRD01_TBLS_BK_ONLY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-AUG-13
Starting Control File and SPFILE Autobackup at 10-AUG-13
piece handle=/backup/rman/ctl_c-758818131-20130808-01 comment=NONE
Finished Control File and SPFILE Autobackup at 10-AUG-13

Once the backup is finished, if you view the files from rman directory, you’ll not see the tag name here. Tag name is used only from RMAN repositories to view and restore backups. So, now you see there are more files in this directory, as we’ve taken couple of backups.

$ ls -l /backup/rman/
total 29176
-rw-r----- 1 oracle dba 14585856 Aug  8 11:48 ctl_c-758818131-20130808-00
-rw-r----- 1 oracle dba 14585856 Aug  8 11:54 ctl_c-758818131-20130808-01
-rw-r----- 1 oracle dba   327680 Aug  8 11:48 full_4dogpd0u_4237_1
-rw-r----- 1 oracle dba   327680 Aug  8 11:54 full_4fogpdb3_4239_1

 

5. Change Oracle RMAN Backup File Name Format

If you want the backup files itself will be in a specific format, you need to change the format in the RMAN configuration as shown below. In this example, we’ve appended the tag “full_devdb_bk_” prefix to all our backup files.

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   "/backup/rman/full_devdb_bk_%u_%s_%p" MAXPIECESIZE 2048 M;

Now, let us take another backup with this modified configuration.

RMAN> BACKUP AS BACKUPSET TAG 'WEEEKLY_PRD01_TBLS_BK_ONLY' TABLESPACE PRD01;

Now when you view the RMAN files, you’ll see the new RMAN backup file has this new file name format for the files. This is easier to identify certain information about the backup just by looking at the file names.

$ ls -l /backup/rman/
total 43764
-rw-r----- 1 oracle dba 14585856 Aug  8 11:48 ctl_c-758818131-20130808-00
-rw-r----- 1 oracle dba 14585856 Aug  8 11:54 ctl_c-758818131-20130808-01
-rw-r----- 1 oracle dba 14585856 Aug  8 11:56 ctl_c-758818131-20130808-02
-rw-r----- 1 oracle dba   327680 Aug  8 11:48 full_4dogpd0u_4237_1
-rw-r----- 1 oracle dba   327680 Aug  8 11:54 full_4fogpdb3_4239_1
-rw-r----- 1 oracle dba   327680 Aug  8 11:55 full_devdb_bk_4hogpdef_4241_1

 

6. Compress a RMAN Backup

If you are taking a backup of a big database, you’ll notice that the RMAN backup files are bigger (almost same size as the database itself).

So, for most situation, you should always tak ea compressed backup of the database.

The following example take a compressed backup of the tablepsace PRD01.

RMAN> BACKUP AS COMPRESSED BACKUPSET TAG 'WEEEKLY_PRD01_TBLS_BK_ONLY' TABLESPACE PRD01;

When you view the backup files from the file system level, you will not see any .gz (or .zip, or .bz2) to indicate that the RMAN has taken a compressed backup. The file naming convention will still follow the same as a non-compressed backup.

$ ls -l /backup/rman/
total 58352
-rw-r----- 1 oracle dba 14585856 Aug  8 11:48 ctl_c-758818131-20130808-00
-rw-r----- 1 oracle dba 14585856 Aug  8 11:54 ctl_c-758818131-20130808-01
-rw-r----- 1 oracle dba 14585856 Aug  8 11:56 ctl_c-758818131-20130808-02
-rw-r----- 1 oracle dba 14585856 Aug  8 11:59 ctl_c-758818131-20130808-03
-rw-r----- 1 oracle dba   327680 Aug  8 11:48 full_4dogpd0u_4237_1
-rw-r----- 1 oracle dba   327680 Aug  8 11:54 full_4fogpdb3_4239_1
-rw-r----- 1 oracle dba   327680 Aug  8 11:55 full_devdb_bk_4hogpdef_4241_1
-rw-r----- 1 oracle dba   127680 Aug  8 11:59 full_devdb_bk_4jogpdl0_4243_1

Note: The way to tell whether RMAN has take a compressed backup or not, it by looking at the size, and by looking at the output of the RMAN “list” command which is shown in one of the section below.

7. View all RMAN Backups

To view all the RMAN backups, execute “list backup summary” as shown below.

RMAN> LIST BACKUP SUMMARY;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
..
4215    B  F  A DISK        10-AUG-13       1       1       NO         TAG20130808T114846
4216    B  F  A DISK        10-AUG-13       1       1       NO         TAG20130808T114849
4217    B  F  A DISK        10-AUG-13       1       1       NO         WEEEKLY_PRD01_TBLS_BK_ONLY
4218    B  F  A DISK        10-AUG-13       1       1       NO         TAG20130808T115413
4219    B  F  A DISK        10-AUG-13       1       1       NO         WEEEKLY_PRD01_TBLS_BK_ONLY
4220    B  F  A DISK        10-AUG-13       1       1       NO         TAG20130808T115600
4221    B  F  A DISK        10-AUG-13       1       1       YES        WEEEKLY_PRD01_TBLS_BK_ONLY

As you see above, it displays various information about the backups. In the above output, it show 7 RMAN backups. The last column shows the “Tag” that we specified when we took a backup. If we didn’t specify any TAG, RMAN creates a default tag with the prefix “TAG” followed by some numbers. You can also see that under the column “Compressed”, the last RMAN backup shows “YES”, which indicates that out of all the 7 RMAN backups, only the last one was compressed.

Also, when the RMAN backup is running, if you want to see the proress, you can query the V$RMAN_STATUS table from sql*plus as shown below.

SQL> SELECT OPERATION, STATUS, MBYTES_PROCESSED, START_TIME, END_TIME from V$RMAN_STATUS;

OPERATION                         STATUS                  MBYTES_PROCESSED START_TIM END_TIME
--------------------------------- ----------------------- ---------------- --------- ---------
CONTROL FILE AND SPFILE AUTOBACK  COMPLETED                             14 07-NOV-12 07-NOV-12
RMAN                              COMPLETED                              0 07-NOV-12 07-NOV-12
RESTORE VALIDATE                  COMPLETED                              0 07-NOV-12 07-NOV-12
RMAN                              COMPLETED WITH ERRORS                  0 07-NOV-12 07-NOV-12
DELETE                            COMPLETED                              0 08-NOV-12 08-NOV-12
BACKUP                            COMPLETED                              0 10-AUG-13 10-AUG-13
CONTROL FILE AND SPFILE AUTOBACK  COMPLETED                             14 10-AUG-13 10-AUG-13
RMAN                              COMPLETED WITH ERRORS               1832 10-AUG-13 10-AUG-13
RMAN                              COMPLETED                              0 10-AUG-13 10-AUG-13
...

There you have it.
That is how you take an Oracle RMAN backup.

Share

Oracle Database : How to Shutdown Oracle Database – Shutdown Basics

October 3rd, 2018, posted in Oracle Queries
Share

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.Problem sys@standby> startup mount; ORACLE instance started. Total System Global Area 835104768 bytes Fixed Size 2217952 bytes Variable Size 490735648 bytes Database Buffers 335544320 bytes Redo Buffers 6606848 bytes Database mounted. sys@standby> alter database recover managed standby database using current logfile disconnect; alter database recover managed standby database using current logfile disconnect * ERROR at line 1: ORA-01153: an incompatible media recovery is active Cause This indicates a currently running media recovery process. Action sys@standby> alter database recover managed standby database cancel; sys@standby> alter database recover managed standby database using current logfile disconnect; Note When shutting down physical standby database, firstly turn off media recovery process. Otherwise the next time when starting up redo apply again, you will encounter error ORA-01153.

Database Shutdown

During a database shutdown we close the database and terminates the instance.

Different Modes in Database Shutdown
There are different modes to bring down the database:
1. Shutdown immediate
2. Shutdown transactional
3. Shutdown normal
4. Shutdown abort
No 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 normal


Shutdown Abort

– Oracle Closes the datafiles without any checkpoint.
– This is the fastest shutdown mode.
– Instance recovery is required in the next startup and hence it will take time.

$ 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 online datafiles 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 from the 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

Share