Upload
santababu
View
1.283
Download
5
Embed Size (px)
DESCRIPTION
Details about RMAN configuration and backup senario.
Citation preview
RMAN KEY FEATURES
RMAN, Recovery Manager, is a tool to backup, restore and recover Oracle databases
Can store frequently executed commands as scripts, independent of OS
Empty blocks are not copied Provides incremental backup feature to copy only
changed blocks Can deduct block corruption while taking backup Parallelize operation to reduce backup time Can reduce reads per file, thus minimizing impact to
database performance
CONFIGURING TARGET DATABASE
CONNECTING TO THE TARGET DATABASE SSh –X oracle10g @ 10.1.15.91
CREATING LISTENER Go to netmgr and add a listener
CREATING CONNECTION DESCRIPTOR Add a connection descriptor in netmgr(con_tar)
STARTING LISTENER Start listener using lsnrctl
CONFIGURING CATALOG DATABASE
CREATE LISTENERo Go to netmgr and add a listener
CREATING CONNECTION DESCRIPTORo Add a connection descriptor in netmgr(con_cat)
STARTING LISTENERo Start listener using lsnrctl
CREATING CATALOG USER
BEFORE CREATING THE CATALOG USER WE WANT TO CREATE A CATALOG TABLESPACE TO HOLD THE CATALOG
Create tablespace cat_tbsDatafile ‘/home/oracle/product/10.2.0/oradata/cat_tbs.dbf’ size 100m
Create user cat identified by catDefault tablespace cat_tbsTemporary tablespace tempQuota unlimited on cat_tbs
Grant connect,resource to cat
Grant recovery_catalog_owner to cat
STEPS TO BE FOLLOWED BEFORE CONNECTING
Database should be in archive log mode
Listeners should be started in both the target and catalog database
Recovery catalog database should be always up and running
Target database should be in the mount phase (to read control files)
CONNECTING THROUGH RMAN
$ RMAN
RMAN > Connect target sys/sys@con_tar
RMAN > Connect catalog cat/cat@con_cat
RMAN > Create catalog tablespace cat_tbs
RMAN > Register database
CONFIGURING RMAN FOR BACKUP
RMAN> show all;
RMAN configuration parameters are:CONFIGURE RETENTION POLICY TO REDUNDANCY 2;CONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK;CONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/%F;# defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 1; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/home/oracle/bkp/rman/backup %d_S_%s_P_%p_T_%t';CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/9.2.0/dbs/snapcf_ORA920.f'; # default
RMAN Backup Types
Fullbackup of a data file that includes every allocated block in the file being backed up
Incremental level 0 –Backup of every block except blocks compressed outLevel 1- includes blocks that have been changed since the parent backup was taken.
OpenA backup of online, read/write datafiles when the database is open.
ClosedA backup of any part of the target database when it is mounted but not open. Closed backups can be consistent or inconsistent.
ConsistentBackup taken when the database is mounted (but not in open),after proper shutdown.checkpoint SCNs in the datafile headers match the header information in the control file.
InconsistentA backup of any part of the target database when it is open or when a crash occurred or SHUTDOWN ABORT was run prior to mounting.An inconsistent backup requires recovery to become consistent.
Various backup using RMAN
Backing up Entire Databaserman target sys/sys@con_tar catalog cat/cat@con_cat
RMAN>backup database; ( will backup data file , control file)
Backing up the archived logsRMAN>backup archivedlog :
(will backup all archivedlog which haven’t backedup before)
RMAN>backup database plus archivedlog ; (Will backup data file+Archived log)
Backing up control file :RMAN>backup current controlfile; ( will backup current contolfile).
Backingup tablespace :RMAN>backup tablespace <tbsname>;
(will backup tablespace DB should be in archivelogmode)
Backing datafile:
RMAN>backup datafile ‘<pathname>/<datafile name>’; It will backup datafile in Flash Recovery Area/we can specify a path
INCREMENTAL BACKUPS
• An incremental backup at level n, n > 0, copies only changed blocks since previous incremental backup whose level <= n
• Take a level 0 backup as base line for the succeeding incremental backups
• Can take multilevel incremental backup• Up to five levels of backups can be taken
• Ex:– Level 0 - Base line backup every month– Level 1 - Weekly incremental– Level 2 - Daily incremental
• Cumulative incremental backup can be used to reduce recovery time
• Cumulative incremental backup at level n, n > 0, copies all changed blocks since previous incremental backup whose level < n
• Incremental backup is useful when the database is very large• Cumulative incremental is useful to reduce database down time
during recoveryExample of cumulative incremental backup
In a cumulative level 1 backup, RMAN backs up all the blocks used since the most recent level 0 incremental backup. Cumulative incremental backups reduce the work needed for a restore by ensuring that you only need one incremental backup from any particular level. Cumulative backups require more space and time than differential backups, however, because they duplicate the work done by previous backups at the same level.
The following command performs a cumulative level 1 incremental backup of the database:
RMAN>BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;Example of differential incremental backup
In a differential level 1 backup, RMAN backs up all blocks that have changed since the most recent cumulative or differental incremental backup, whether at level 1 or level 0. RMAN determines which level 1 backup occurred most recently and backs up all blocks modified after that backup. If no level 1 is available, RMAN copies all blocks changed since the level 0 backup.
The following command performs a level 1 differential incremental backup of the database:
RMAN> BACKUP INCREMENTAL LEVEL 1 differential DATABASE;
Recovery
Decide your scenario Lost controlfile Lost datafile
Lost entire database
Restore
• Restore database - Restores entire database including controlfile• Restore datafile <filename> - Restores specific datafiles • Restore tablespace <tablespace_name> - Restores all datafiles
belongs to tablespace.• Restore controlfile - Restores only controlfile• Restore archivelog all - Restores all archivelog files.
RECOVERIf restore completed successfully then following command can be executed based on the recovery scenario.
– Recover database - Recovering entire database – Recover datafile <filename> - Recovering specific
datafiles – recover tablespace <tablespace_name> - Recovering all
datafiles belongs to the tablespace– recover database until cancel - Recovering database until
canel– recover database until time = <TIME> - Until time– recover database until SCN = <SCN> - Until Specific
SCN– recover database until SEQUENCE =<SEQ> - Until specific
sequence
SQL> select file#, error, online_status, change#, time from v$recover_file;
Will give details details about the files you need to restore and recover
SCENARIOS
Scenario 1 Recover full database
Need to recover full database including controlfile, If we have backup then we can start recovery.
RmanRMAN > Connect target sys/sys@con_tarRMAN > connect catalog cat/cat@con_catRMAN > startup nomountRMAN > run { restore database; alter database mount; recover database; }
Scenario 2 Recover Lost controlfile
• Target database
Shut abort Startup nomount
• Connect to rman catalog and target database
RMAN > run { Restore controlfile; alter database mount; recover database; alter database open resetlogs; }
Scenario 3 Recover lost datafile
RMAN> RUN { alter tablespace sysaux offline;
restore datafile ‘/home/oracle10g/data/sysaux1.dbf';
recover datafile ‘/home/oracle10g/data/sysaux1.dbf';
alter tablespace sysaux online}
Scenario 4 Recover lost tablespace
RMAN>run{ alter tablespace sysaux offline restore tablespace sysaux recover tablespace sysaux alter tablespace sysaux online}
Sandeep kumar SinhaSembiyan.vEmail-- [email protected]