Case Study #1 - Backup, Recovery and No-Archivelog
Case Study #1 - Backup, Recovery and No-Archivelog
NO-ARCHIVELOG)
by Jeff Hunter, Sr. Database Administrator
Contents
1. Introduction to Oracle RMAN Case Studies
2. Case Study Overview
3. Configuring RMAN parameters
4. Backup the Target Database
5. Performing Validation
6. Maintenance Commands
7. Remove the TARGDB Database
8. Restoring and Recovering the Target Database
RMAN>
Configuring RMAN parameters
RMAN (Oracle9i and higher) allows the DBA to perform
automated database backup and recovery. This feature is
supported by RMAN with its ability to define default
values for a number of settings, (i.e. channel
configuration, parallelism, automated backup of the
controlfile). Setting RMAN parameters is done using the
configure command.
Script: configure_database.rcv
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE
TYPE DISK TO '/orabackup1/rman/TARGDB/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT
'/orabackup1/rman/TARGDB/backup_db_%d_S_%s_P_%p_T_%t'
MAXPIECESIZE 1024m;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT
'/orabackup2/rman/TARGDB/backup_db_%d_S_%s_P_%p_T_%t'
MAXPIECESIZE 1024m;
}
NOTE: All configuration settings are stored
persistently, and will be used by RMAN for all
subsequent backup, restore, recovery, and
maintenance operations.
NOTE: It is important that you save the database id
(DBID) displayed in the RMAN output if you are taking
RMAN backups in NOCATALOG mode or if the
database name is ambigious in the Recovery Catalog.
The DBID is required during disaster recovery! You
will see the DBID in RMAN output when connecting
to the target database as in the following output:
% rman target backup_admin/backup_admin
Script: backup_cold.rcv
run {
# -----------------------------------------------------------
# The following RMAN commands are run each day.
# The steps are:
# - Re-start the database to perform crash recovery, in
# case the database is not currently open, and was not
# shut down consistently. The database is started in DBA
# mode so that normal users cannot connect.
# - Shut down with the IMMEDIATE option to close the
# database consistently.
# - Startup and mount the database.
# - Backup database.
# - Open database for normal operation.
# -----------------------------------------------------------
startup force dba;
shutdown immediate;
startup mount;
backup database;
alter database open;
}
exit
Performing Validation
The following commands can be run any time to check if
RMAN is capable of restoring the database (or a
tablespace) using existing backups.
Use the following to verify that a the entire database can
be restored using the existing backups:
run {
restore database validate;
}
Maintenance Commands
RMAN provides several commands that can be used for
maintenance:
Script: maintenance_commands.rcv
run {
# -----------------------------------------------------------
# Verify that all backups on the backup media are intact
# -----------------------------------------------------------
CROSSCHECK BACKUP OF DATABASE;
# -----------------------------------------------------------
# Display a list of files that need to be backed up based on
# the retention policy. For this case study, files that don't
# have at least 2 backups will be reported.
# -----------------------------------------------------------
REPORT NEED BACKUP;
# -----------------------------------------------------------
# Delete any un-necessary backups. This command deletes
backups
# based on the retention policy you configured. For this case
study, all
# backups older than the 2 most recent backups of each
# datafile will be deleted.
# -----------------------------------------------------------
DELETE OBSOLETE;
# -----------------------------------------------------------
# Get a complete summary list of existing backups.
# -----------------------------------------------------------
LIST BACKUP SUMMARY;
}
Remove the TARGDB Database
In this section, I want to remove the TARGDB database to
simulate and setup a disaster recovery situation. If the
instance is still running, it will need to be shutdown:
% rm /u03/app/oradata/TARGDB/*
% rm /u04/app/oradata/TARGDB/*
% rm /u05/app/oradata/TARGDB/*
% rm /u06/app/oradata/TARGDB/*
SQL> exit
Script: recover_cold.rcv
set dbid 2528050866;
run {
# -----------------------------------------------------------
# Uncomment the SET UNTIL command to restore database to
the
# incremental backup taken two days ago.
# SET UNTIL TIME 'SYSDATE-2';
# -----------------------------------------------------------
set controlfile autobackup format for device type disk to
'/orabackup1/rman/TARGDB/%F';
restore controlfile from autobackup;
alter database mount;
restore database;
recover database noredo;
alter database open resetlogs;
sql "alter tablespace temp add tempfile
''/u06/app/oradata/TARGDB/temp01.dbf''
size 500m autoextend on next 500m maxsize 1500m";
}
exit