How to Backup and Restore a RAC Database


This example illustrates how to backup and recover a 2-node, 10gR2 RAC cluster on Linux. Backup and recovery operations for RAC databases are similar to that of single instance databases, however there are some key differences – the goal of this post is to highlight the steps required for recoverying RAC databases.

Backup the DatabaseUse the method you prefer. I used a NOCATALOG, disk-based backup for this example, using the scripts foundSimulate the Failure

Shutdown the database and simulate a failure by dropping and/or corrupting a datafile.

# export ORACLE_SID=em1
# . oraenv
# srvctl stop database -d em
# srvctl status database -d em
Instance em1 is not running on node rac1
Instance em2 is not running on node rac2

# cd /u02/oracle/ora1/em

# rm sysaux01.dbf

Verify the Failure

# srvctl start instance -d em -i em1
PRKP-1001 : Error starting instance em1 on node rac1
CRS-0215: Could not start resource 'ora.em.em1.inst'.

Continue reading

Advertisements

Incrementally Updated Backups: A One Week Example


The basic example can be extended to provide fast recoverability to a window greater
than 24 hours. Alter the RECOVER COPY… WITH TAG to perform incomplete
recovery of the datafile copies to the point in time in the past where you want your
window of recoverability to begin. This example shows how to maintain a seven day
window:
RUN {
RECOVER COPY OF DATABASE WITH TAG ‘incr_update’
UNTIL TIME ‘SYSDATE – 7’;
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG ‘incr_update’
DATABASE;
}
The effect of the script is as follows:
■ On the first night the RECOVER COPY… UNTIL TIME statement has no effect,
and the BACKUP INCREMENTAL… FOR RECOVER OF COPY statement creates
the incremental level 0 copy.
■ On the second through seventh nights, the RECOVER COPY… UNTIL TIME
statement has no effect because TIME ‘SYSDATE – 7’ is still a time in the
future. The BACKUP INCREMENTAL… FOR RECOVER OF COPY statement
creates differetial incremental level 1 backups containing the block changes for the
previous day.
■ On the eighth and all subsequent nights night, the RECOVER COPY… UNTIL
TIME statement applies the level 1 incremental from seven days ago to the copy of
the database. The BACKUP INCREMENTAL… FOR RECOVER OF COPY
statement creates an incremental backup containing the changes for the previous
day.
As with the basic example, you have fast recoverability to any point in time between
the SCN of the datafile copies and the present, using block changes from the

incremental backups and individual changes from the redo logs. Because you have the
daily level 1 incrementals, you still never need to apply more than one day of redo.

Performing a Point-in-Time Recovery use SCN


In this exercise, you will do a point-in-time recovery by restoring the database to a previous SCN.

1. Back up the database. Details on how to do a full online database backup are found in online backup. In summary, follow these steps:

  • First put the database in hot backup mode.
  • Copy all database datafiles to a backup location.
  • Take the database out of hot backup mode.
  • Force a log switch. Back up the archived redo logs.

Here is an example of a backup:

[oracle@localhost orcl]$ sqlplus “/ as sysdba”

SQL*Plus: Release 11.1.0.6.0 – Production on Sun Aug 17 15:35:48 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Continue reading

Restoring a Database Using a Cold Backup (Offline Backup)


In this exercise you will be restoring the database with a cold backup. It is assumed the database is in NOARCHIVELOG mode.
1. Make sure the database is shut down.
2. Copy the files on the backup media to the original location. You would copy the following files:

  • NN Database datafiles
  • NN Database control files
  • NN Database online redo logs

If the original location of the database files is not available, copy them to an alternate location. Having copied the files to an alternate location, you will likely need to execute an optional step 3 for the control files and optional step 4 for all database files and/or online redo logs. Here is an example of the copy command:

Continue reading

Creating a Trace File with the Create Control File


If all else fails and you do not have a backup control file, don’t worry; you have another option, the create controlfile command. Normally, manually executing the command can be challenging because you need to know a lot of information about your database (like the names and locations of all the database datafiles). However, you can prepare for the possibility of having to use the create controlfile command by creating one in advance.
The alter database backup controlfile to trace command will create a trace file with the create controlfile command in it for you. The trace file is stored in the new diagnostic directory structure in Oracle Database 11g. The diagnostic directory structure is a new standard introduced in Oracle Database 11g that defines where Oracle stores files related to database troubleshooting and diagnostics.The base directory of this structure is defined by the parameter DIAGNOSTIC_DEST. Here is an example of the setting of DIAGNOSTIC_DEST on an Oracle database:
SQL> show parameter diag
NAME TYPE VALUE
———————————— ———– ———
diagnostic_dest string C:\ORACLE

Continue reading

Creating a Backup Control File


The backup control file is almost the same as a regular control file. It has some areas in it that are marked such that Oracle recognizes that it’s a backup control file. When a backup control file is used, some form of recovery will be required (typically just involving the use of the archived and online redo logs if the database is otherwise intact).To create the backup control file simply issue the alter database backup controlfile to command, indicating at the end of the command where you want the control file to be created.
For example, if you wanted to create a backup control file after the online backup , you would simply need to issue the following command:
SQL> alter database backup controlfile to ‘c:\backup\orcl\backup2\backup_control.ctl’;
Database altered.
The result is the creation of a backup control file called backup_control.ctl found in the c:\backup\orcl\backup2 directory, as you can see here:

Continue reading