Recovery Management (RMAN)
—————————————-
API:DBMS_rcvman, DBMS_rcvcat,DBMS_backup_restore
VIEWS:RC_database,v$rman_configuration,v$rman_status,
v$session, v$rman_backup_job_details
BACKUP RETENTION: No. of backup sets, No. of days
FILES: Backup pieces
CONFIGURATION MODES: NO Catalog Mode, Catalog Mode
BACKUP DESTINATION: Disk ,Tape, NFS
3rd PARTY MML SOFTWARES: Tivoli Data Protector for Oracle
HP data protector for Oracle
Veritas, Legato.
BACKUP TYPES: Full Backup, Incremental/Diffrential Backup, Compressed Backup.
10g/11g New Features: Block Change Tracking (10g),
Compressed Backup (10g),
Backup Encryption (10g),
Channel Failover (10g),
Virtual Private Catalog (11g),
Multi Session Backup (11g).
—————————————————————————
>In catalog mode RMAN keeps the backup information in the reusable section
of the target database controlfile.
>The retention of information in the reusable section of the target database
control file depends on the parameter:
control_record_keep_time [default value is 7 days].
>Even if you specify a bigger value,retention may not be guaranteed since,
controlfile grows upto operating system limitation.
———————————————————————
RMAN INCREMENTAL BACKUP
———————————————————————
>In case of incremental backup, RMAN takes the backup of only modified blocks.
>The different levels of incremental are:
1.Level 0 [Complete]
2.Level 1 [Incremental]
3.Level 2 [Cumulative]
>In order to take incremental backup, first we need to take level 0 backup.
>Without taking level 0, if we initiate level 1, by dfeault RMAN takes
level 0 backup.
>In order to minimize incremental backup time, In 10g oracle has introduced
block change tracking.
SQL> alter database enable block change tracking using file ‘/opt/changetrack.file’;
>From 10.2.0.4 ,Levels greater than 0 and 1 have become obsolete.
RMAN> backup incremental level 0 database;
RMAN> backup incremental level 1 database;
RMAN> backup incremental level 2 database;
(or)
RMAN> backup incremental level 1 cumulative database;
————————————————-
Weekly Backup Script
————————————————-
RMAN> create script weekly-backup
SQL ‘alter system switch logfile’;
backup incremental level 0 database plus archivelog delete all input;
SQL ‘alter system switch logfile’;
RMAN>Run {
execute script weekly-backup;};
RMAN>crosscheck archivelog all;
RMAN>backup database plus archivelog delete all input;
—————————————————————————————–
RMAN NO CATALOG MODE (BACKUP & RECOVERY SCENARIOS)
—————————————————————————————–
[email protected]> su – oracle
[email protected]> export ORACLE_SID=hrms
[email protected]> sqlplus / as sysdba
SQL> startup
[email protected]> export ORACLE_SID=hrms
[email protected]> which rman
[email protected]> rman target /
(or)
[email protected]> rman nocatalog target /
(or)
[email protected]> rman
RMAN >connect target /
RMAN> shutdown immediate
[email protected]> rman target /
RMAN> startup
RMAN> show all;
SQL> select * from v$rman_configuration;
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN> show all;
RMAN> spool log to rman.log
RMAN> show all;
RMAN> spool off;
RMAN> exit
[email protected]> vi rman.log
:set nu
1.CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
2.BACKUP OPTIMIZATION ON; (it takes the backup of read only files at first time)
3.DEVICE TYPE TO DISK;
4.CONTROL FILE AUTOBACKUP ON;
5……….AUTO BACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/U03/rmanbackup/%F’
(default it takes ORACLE_HOME/dbs)
at the end of file,
6.CONFIGURE ENCRYPTION FOR DATABASE ON/OFF;
7.CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1/2;
(takes the copies of backup in archivelog mode)
8.CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUP SET;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT ‘/u03/rmanbackup/%U’;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT ‘/u03/rmanbackup/%U’;
:wq
Create a structure of RMAN Backup:
———————————————-
[email protected]>mkdir -p /u03/rmanbackup
[email protected]>chown -R oracle:oinstall /u03/rmanbackup
[email protected]>chmod -R 775 /u03/rmanbackup
[email protected]> su – oracle
[email protected]>export ORACLE_SID=hrms
[email protected]> rman target /
RMAN> @rman.log
RMAN>show all;
RMAN>report schema;
RMAN>report need baackup;
—————————————————————-
Taking Backups and Recovery Scenario’s
—————————————————————-
1.Take the backup of the datafile.
——————————————
RMAN> backup datafile 4;
[email protected] rmanbackup> ls
RMAN > report need backup;
To see obsolete Backup:
——————————-
RMAN> report obsolete;
RMAN> backup datafile 4;
RMAN> report need backup;
RMAN> backup datafile 4;
[email protected] rmanbackup> ls
RMAN> report obsolete;
RMAN> show all;
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
RMAN> report obsolete;
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN>report obsolete;
2.Delete all obsolete backup’s :
—————————————
RMAN> delete obsolete;
RMAN> delete noprompt obsolete;
RMAN> report obsolete;
3.To See Existing Backups:
———————————–
RMAN> List backup;
RMAN> List backup summary;
4.Deleting the backup:
—————————-
RMAN> delete noprompt backup;
(automatically it deletes os level backup also)
[email protected] rmanbackup> ls
RMAN> list backup;
RMAN> backup datafile 4;
RMAN> list backup;
RMAN> delete backupset 7;
RMAN> list backup;
5.Remove File at OS Level:
———————————–
[email protected] rmanbackup> rm * (or) rm c-73…………….
RMAN> List backup;
RMAN> crosscheck backup;
(It checks whether the backup is available at os level or not)
RMAN> list backup;
RMAN> delete noprompt expired backup;
RMAN> list backup;
RMAN> report schema;
6.Taking backup of tablespaces:
—————————————–
RMAN> backup tablespace users;
RMAN> backup current controlfile;
RMAN> backup spfile;
RMAN> backup archivelog all;
RMAN> List archivelog all;
7.Taking Full database backup:
——————————
RMAN> backup database plus archivelog;
—————————————————————
RECOVERY SCENARIOS:
—————————————————————
1. Loss of Full Database:
——————————–
RMAN> report schema;
[email protected]> cd /u02/app/oracle/hrms/
hrms>rm *
hrms>cd /u01/app/oracle/fast_recovery_area/hrms/
RMAN> validate database; (If database is not in proper way)
RMAN> shutdown abort;
RMAN> startup nomount;
RMAN> restore controlfile from ‘/u03/rmanbackup/c-765432———‘;
RMAN> alter database mount;
RMAN> restore database;
RMAN> recover database;
RMAN> sql ‘alter database open resetlogs’;
2.Loss of non-system datafiles:
—————————————-
[email protected]> export ORACLE_SID=hrms
[email protected]> rman target /
RMAN> report schema;
[email protected]> cd /u02/app/oracle/hrms/
hrms>ls
hrms>
hrms> rm users01.dbf
RMAN> validate database;
(Note:its a non-system datafile so no need to shutdown)
RMAN> sql ‘alter database datafile 4 offline’;
RMAN> restore datafile 4;
RMAN> recover datafile 4;
RMAN> sql ‘alter datbase datafile 4 online’;
RMAN> validate database;
RMAN> report schema;
(or) Method:2
RMAN> report schema;
[email protected]> cd /u02/app/oracle/hrms/
hrms> ls
hrms> rm users01.dbf
RMAN> validate database;
RMAN> List failure;
RMAN> advise failure;
RMAN> repair failure;
3:Loss of system datafile:
———————————
RMAN> report schema;
[email protected]> cd /u02/app/oracle/hrms/
hrms> ls
hrms> rm system01.dbf
RMAN> validate database;
RMAN> shutdown abort;
[email protected]> export ORACLE_SID=hrms
[email protected]> rman target /
RMAN> startup mount;
RMAN> restore datafile 1;
RMAN> recover datafile 1;
RMAN> alter database open;
4.Loss of controlfiles:
—————————-
[email protected]> rman target /
[email protected]> export ORACLE_SID=hrms
[email protected]> sqlplus / as sysdba
[email protected]> cd /u02/app/oracle/hrms/
[email protected]> rm comtrol01.ctl
[email protected]> cd /u01/app/oracle/fast_recovery_area/hrms/
[email protected]> rm control02.ctl
RMAN> validate database;
RMAN> shut abort;
error:
[email protected]> export ORACLE_SID=hrms
[email protected]> sqlplus / as sysdba
SQL> shut abort
[email protected]> rman target /
RMAN> startup nomount
RMAN> restore controlfile from ‘/u03/rmanbackup/c-76539872———‘;
RMAN> alter database mount;
RMAN> recover database;
RMAN> sql ‘alter database open resetlogs’;
5.Loss of Redo Log Files:
———————————
[email protected]> cd /u02/app/oracle/hrms/
hrms> ls
hrms> rm *.log
RMAN> shutdown abort;
RMAN> startup mount;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;
Error: ORA-01110 datafile 1: ‘/u02/app/oracle/hrms/system01.dbf’
RMAN> List Failure;
RMAN> advise failure;
Repair script: /u01/…………….
RMAN> @ /u01/app/oracle…………………………../reco………hm
[email protected]> cat /u01/appp/oracle………/reco/hm
RMAN> alter database open resetlogs;