Block Media Recovery
check the corrupted block using following sql command.
SQL> select * from v$ database_block_corruption;
Now recover block.
RMAN> recover datafile 4 block 204;
Control file recovery
RMAN> restore controlfile;
Restore the tablespace
First check the missing tablespace by following sql.
SQL> select * from v$datafile_header;
RMAN> report schema;
RMAN> sql 'alter tablespace <ts> offline immediate';
RMAN> restore tablespace <ts>;
RMAN> recover <ts>;
RMAN> sql 'alter tablespace <ts> online';
Restoring a datafile.
RMAN> Restore datafile 4;
RMAN> recover datafile 4;
Restoring a Entire Database
RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;
Other RMAN useful commands that you need to know.
RMAN> list failure;
RMAN> list failure 1020 detail;
RMAN> advice failure;
RMAN> list backup summary;
RMAN> report schema at time '20-dec-11';
RMAN> report schema;
=================================================
Now check a practical RMAN shell scripts written for backing up a big Analytics production database.
----------------------
RMAN full backup scripts which is scheduled to run once in weekend.
. /sky/oracle/.profile
dt=`date +"%d.%m.%Y"`
rman <<EOF
spool msglog to '$HOME/CRON_LOGS/RMANFULLlogs/rman_FULL_$dt.log'
connect target /
crosscheck archivelog all;
run{
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/s1/ors/backup01/rmanbackup/control_backup/controlfile_Weekly%F.trc';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/s1/ors/backup01/rmanbackup/control_backup/snap_control_file_Weekly_PORS.f';
CONFIGURE DEVICE TYPE DISK PARALLELISM 6;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 5 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 6 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
BACKUP as compressed backupset incremental level 0 DATABASE PLUS ARCHIVELOG;
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
}
EXIT;
EOF
-----------------------------------
Now, we have written incremental backup scripts.
RMAN incremental backup unix scripts
. /sky/oracle/.profile
dt=`date +"%d.%m.%Y"`
rman <<EOF
spool msglog to '$HOME/CRON_LOGS/RMANlogs/rman_INC_$dt.log'
connect target /
crosscheck archivelog all;
run {
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/sky1/UORSrmanbkp/INC/controlfile_Daily%F.trc';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/sky1/UORSrmanbkp/INC/snap_control_file_Daily_PORS.f';
CONFIGURE DEVICE TYPE DISK PARALLELISM 6;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 5 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 6 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
BACKUP as compressed backupset incremental level 1
DATABASE PLUS ARCHIVELOG;
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
}
-------------------------
Now schedule the above RMAN scripts using crontab utility in Unix box.
$crontab -e
00 01 * * 0,1,2,3,4,5 sh $HOME/scripts/sky_inc_rmanbkp.sh 1>$HOME/CRON_LOGS/RMANINClogs/RmanINCbkp.log 2>$HOME/CRON_LOGS/RMANINClogs/RmanINCbkp.err
00 01 * * 6 sh $HOME/scripts/sky_full_rmanbkp.sh 1>$HOME/CRON_LOGS/RMANFULLlogs/RmanFULLbkp.log 2>$HOME/CRON_LOGS/RMANFULLlogs/RmanFULLbkp.err
00 23 * * 6 rm /sky-backup/INC/* 1>$HOME/CRON_LOGS/RMANINClogs/old_INC_delete.log
30 23 * * 6 rm /sky-backup/FULL/* 1>$HOME/CRON_LOGS/RMANINClogs/old_FULL_delete.log
--------------------------
You can also delete old archive log files as it's been backed up in RMAN.
moving archivelog file to other location ->
find . -type f -name '*.arc' -mtime +2 -exec gzip {} \; & to gzip
=================================================
Oracle RMAN Tutorial Part 3 Recovery Operation
check the corrupted block using following sql command.
SQL> select * from v$ database_block_corruption;
Now recover block.
RMAN> recover datafile 4 block 204;
Control file recovery
RMAN> restore controlfile;
Restore the tablespace
First check the missing tablespace by following sql.
SQL> select * from v$datafile_header;
RMAN> report schema;
RMAN> sql 'alter tablespace <ts> offline immediate';
RMAN> restore tablespace <ts>;
RMAN> recover <ts>;
RMAN> sql 'alter tablespace <ts> online';
Restoring a datafile.
RMAN> Restore datafile 4;
RMAN> recover datafile 4;
Restoring a Entire Database
RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;
Other RMAN useful commands that you need to know.
RMAN> list failure;
RMAN> list failure 1020 detail;
RMAN> advice failure;
RMAN> list backup summary;
RMAN> report schema at time '20-dec-11';
RMAN> report schema;
=================================================
Now check a practical RMAN shell scripts written for backing up a big Analytics production database.
----------------------
RMAN full backup scripts which is scheduled to run once in weekend.
. /sky/oracle/.profile
dt=`date +"%d.%m.%Y"`
rman <<EOF
spool msglog to '$HOME/CRON_LOGS/RMANFULLlogs/rman_FULL_$dt.log'
connect target /
crosscheck archivelog all;
run{
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/s1/ors/backup01/rmanbackup/control_backup/controlfile_Weekly%F.trc';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/s1/ors/backup01/rmanbackup/control_backup/snap_control_file_Weekly_PORS.f';
CONFIGURE DEVICE TYPE DISK PARALLELISM 6;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 5 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
CONFIGURE CHANNEL 6 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/FULL/backup_Weekly_%D_%s_%p_%t.rman' MAXPIECESIZE 2048M;
BACKUP as compressed backupset incremental level 0 DATABASE PLUS ARCHIVELOG;
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
}
EXIT;
EOF
-----------------------------------
Now, we have written incremental backup scripts.
RMAN incremental backup unix scripts
. /sky/oracle/.profile
dt=`date +"%d.%m.%Y"`
rman <<EOF
spool msglog to '$HOME/CRON_LOGS/RMANlogs/rman_INC_$dt.log'
connect target /
crosscheck archivelog all;
run {
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/sky1/UORSrmanbkp/INC/controlfile_Daily%F.trc';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/sky1/UORSrmanbkp/INC/snap_control_file_Daily_PORS.f';
CONFIGURE DEVICE TYPE DISK PARALLELISM 6;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 5 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
CONFIGURE CHANNEL 6 DEVICE TYPE DISK FORMAT '/sky1/UORSrmanbkp/INC/rmanbkp_Dly_INC_%D_%s_%p_%t.UORS' MAXPIECESIZE 4096M;
BACKUP as compressed backupset incremental level 1
DATABASE PLUS ARCHIVELOG;
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
sql "alter system archive log current";
}
-------------------------
Now schedule the above RMAN scripts using crontab utility in Unix box.
$crontab -e
00 01 * * 0,1,2,3,4,5 sh $HOME/scripts/sky_inc_rmanbkp.sh 1>$HOME/CRON_LOGS/RMANINClogs/RmanINCbkp.log 2>$HOME/CRON_LOGS/RMANINClogs/RmanINCbkp.err
00 01 * * 6 sh $HOME/scripts/sky_full_rmanbkp.sh 1>$HOME/CRON_LOGS/RMANFULLlogs/RmanFULLbkp.log 2>$HOME/CRON_LOGS/RMANFULLlogs/RmanFULLbkp.err
00 23 * * 6 rm /sky-backup/INC/* 1>$HOME/CRON_LOGS/RMANINClogs/old_INC_delete.log
30 23 * * 6 rm /sky-backup/FULL/* 1>$HOME/CRON_LOGS/RMANINClogs/old_FULL_delete.log
--------------------------
You can also delete old archive log files as it's been backed up in RMAN.
moving archivelog file to other location ->
find . -type f -name '*.arc' -mtime +2 -exec gzip {} \; & to gzip
=================================================
Oracle RMAN Tutorial Part 1 Creating and configuring RMAN repository
Oracle RMAN Tutorial Part 2 BACKUP OPERATION
Oracle RMAN Tutorial Part 3 Recovery Operation
No comments :
Post a Comment