RMAN was always puzzle for me until I implemented this on my test env. Since I never worked and used RMAN in my 7 year career as APPS DBA, sometime ago I decided to do some test demo to understand the RMAN backup and recovery tool. After I completed and tested all backup scenerio now I feel its really simple to use and implement, I would like to share some of RMAN test cases which I implemented on my server.
We need to create a catalog first on RMAN Database before start taking backup of target instance, perform the following steps
Step 1) Make a tnsentry of RMAN instance into the target instance
Step 2) Create RMAND tablespace into RMAN Source Instance
CREATE TABLESPACE rmand DATAFILE '/d001/oracle/rmandO1.dbf' SIZE 1024M:
Create RMAN Schema
SQL> CREATE USER rman IDENTIFIED BY rman DEFAULT TABLESPACE rmand TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON rmand;
Grant the following roles to rman user
SQL> GRANT create session TO rman;
SQL> GRANT resource TO rman;
SQL> GRANT recovery_catalog_owner TO rman;
SQL> GRANT execute ON dbms_stats TO rman;
Step 3)
Connect to rman instance and target instance together from target instance server
$ rman target / catalog rman/rman@gepsmv
RMAN> create catalog tablespace rmand;
Note : This will create the rman catalog
RMAN> register database;
Note : Register the target database
You are ready to take a backup from this stage
If your database is in no archive mode, use the following syntax to take cold backup
Test 1)
RMAN> STARTUP FORCE DBA;
RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;
RMAN> run {
allocate channel c1 type disk;
backup database format '/d001/backup/db_t%t_s%s_p%p' FILESPERSET 4;
release channel c1;
}
Note : backup location here is /d001/backup, fileperset 4 means 4 datafiles make one backup set
RMAN> list backupset of database;
Test 2) Take a backup when archive is enable
you can turn on the archive mode using following steps
SQL> shutdown immediate;
startup mount exclusive;
alter database archivelog;
alter database open;
alter system switch logfile;
make the entry in the Init.ora of the following parameter
log_archive_dest = '/d001/arch'
log_archive_start = true
Backup in Archive Mode
Full Backup ->
rman target / catalog rman/rman@gepsmv
run {
allocate channel c1 type disk;
backup database format '/d001/backup/db_t%t_s%s_p%p' FILESPERSET 4;
release channel c1;
}
Archive Backup ->
run {
allocate channel dev1 type disk;
backup
format '/d001/backup/db_t%t_s%s_p%p'
(archivelog all);
release channel dev1;
}
Need to start recovery after deleting datafile mvd02.dbf from running database
Recovery test1 ->
mv mvd02.dbf mvd02.dbf.old
rman target / catalog rman/rman@gepsmv
RUN
{
allocate channel dev1 type disk;
SQL 'ALTER DATABASE DATAFILE 7 OFFLINE';
restore datafile 7;
recover datafile 7;
SQL 'ALTER DATABASE DATAFILE 7 ONLINE';
release channel dev1;
}
Note : Datafile 7 is file number of mvd02.dbf, you can check it from v$datafile
Recovery Test 2 ->
Tablespace Recovery (Assuming datafiles belong to mvd tablespace has been damaged)
move the files mvd01.dbf & mvd02.dbf while db is running.
RUN
{
allocate channel dev1 type disk;
SQL 'ALTER TABLESPACE MVD OFFLINE immediate';
RESTORE TABLESPACE MVD;
recover TABLESPACE MVD;
SQL 'ALTER TABLESPACE MVD ONLINE';
release channel dev1;
}
Recovery Test3 ->
System File Recovery
rman target / catalog rman/rman@gepsmv
RUN
{
allocate channel dev1 type disk;
SQL 'ALTER DATABASE DATAFILE 1 OFFLINE';
restore datafile 1;
recover datafile 1;
SQL 'ALTER DATABASE DATAFILE 1 ONLINE';
release channel dev1;
Recover Test 4 ->
Complete Restore
rman target / catalog rman/rman@gepsmv
run {
allocate channel dev1 type disk;
restore controlfile to '/d001/oracle/gepsmv/oradata' ;
replicate controlfile from '/d001/oracle/gepsmv/oradata' ;
restore database;
sql "alter database mount";
recover database;
sql "alter database open resetlogs";
release channel dev1;
}
Test 3) Archive Backup with Increment Level
rman target / catalog rman/rman@gepsmv
Increment Level 0 (Base level which is full backup)
# - Take an incremental level 0 backup of the database. A level 0 backup is
# a complete backup of the entire file which can be used as the basis
# for a subsequent incremental backup.
# - Backup all archivelogs that have not already been backed up.
rman target / catalog rman/rman@gepsmv
run {
allocate channel dev1 type disk;
BACKUP INCREMENTAL LEVEL 0 DATABASE FILESPERSET 4 format '/d001/backup/db_t%t_s%s_p%p';
BACKUP ARCHIVELOG ALL;
release channel dev1;
}
rman target / catalog rman/rman@gepsm
run {
allocate channel dev1 type disk;
BACKUP INCREMENTAL LEVEL 1 DATABASE format '/d001/backup/db_t%t_s%s_p%p';
BACKUP ARCHIVELOG ALL;
release channel dev1;
}
Note : Incremental Level 1 is the only changed data after last full backup of incrmental 0
Wednesday, August 27, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment