Rman
description
Transcript of Rman
![Page 1: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/1.jpg)
Backup & Recovery (Oracle 10g) - RMANBackup & Recovery (Oracle 10g) - RMAN
Sandeep Kumar Sinha Sembiyan.V
![Page 2: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/2.jpg)
ARCHITECTUREARCHITECTURE• It is a server based utility.(i.e)it uses oracle server process to
backup,restore and recover
TARGET DATABASE CATALOG DATABASE
RMAN
L L
C.D 1 C.D 2
L – ListenerC.D – Connect descriptor
![Page 3: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/3.jpg)
• TARGET DATABASE – where you carry backup,restore and recovery.
• CATALOG DATABASE – The information regarding the backup will be kept in the recovery catalog database.
• Any backup taken by us will be first stored in control file of the target database,through resynching process the information from the control file of the target database is updated to the recovery catalog.
![Page 4: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/4.jpg)
RMAN Backup TypesRMAN Backup Types• Full
• backup 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 out• Level 1- includes blocks that have been changed since the parent backup was
taken.
• Open• A backup of online, read/write datafiles when the database is open.
• Closed• A backup of any part of the target database when it is mounted but notopen. Closed backups can be consistent or inconsistent.
• Consistent• Backup 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.
• Inconsistent• A 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.
![Page 5: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/5.jpg)
INCREMENTAL BACKUPSINCREMENTAL 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 recovery
![Page 6: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/6.jpg)
CUMULATIVE INCREMENTALCUMULATIVE INCREMENTAL
• 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;
![Page 7: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/7.jpg)
Example of cumulative incremental backup Example of cumulative incremental backup
![Page 8: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/8.jpg)
DIFFERENTIALDIFFERENTIAL
• 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;
![Page 9: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/9.jpg)
Example of differential incremental backup Example of differential incremental backup
![Page 10: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/10.jpg)
STARTING WITH RMANSTARTING WITH RMAN
• Connect to target database
• Create listener
• Create connection descriptor
• Start listener
• Ping
![Page 11: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/11.jpg)
CONFIGURING TARGET DATABASECONFIGURING 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
![Page 12: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/12.jpg)
CONFIGURING CATALOG DATABASE CONFIGURING CATALOG DATABASE
• CREATE LISTENER Go to netmgr and add a listener
• CREATING CONNECTION DESCRIPTOR Add a connection descriptor in netmgr(con_cat)
• STARTING LISTENER Start listener using lsnrctl
• PINGING Check by command –> ping 10.1.15.91
![Page 13: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/13.jpg)
CREATING PASSWORD FILE FOR TARGET DATABASECREATING PASSWORD FILE FOR TARGET DATABASE
• > Startup• > Show parameter spfile• > Alter system set remote_login_passwordfile=exclusive scope=spfile• > shut immediate• cd $ ORACLE_HOME / dbs• $ orapwd file = orapwtarget password = sys• $ cd network/admin• $ vi sqlnet.ora sqlnet.authentication_services = none names.directory_path = (tnsnames)• Target database login issued by RMAN is always sysdba
![Page 14: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/14.jpg)
CREATING CATALOG USERCREATING CATALOG USER
• BEFORE CREATING THE CATALOG USER WE WANT TO CREATE A CATALOG TABLESPACE TO HOLD THE CATALOG
• Create tablespace cat_tbs Datafile ‘/home/oracle/product/10.2.0/oradata/cat_tbs.dbf’ size 100m
• Create user cat identified by cat Default tablespace cat_tbs Temporary tablespace temp Quota unlimited on cat_tbs
• Grant connect,resource to cat
• Grant recovery_catalog_owner to cat
![Page 15: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/15.jpg)
STEPS TO BE FOLLOWED BEFORE CONNECTINGSTEPS 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)
![Page 16: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/16.jpg)
CREATING RMAN CATALOGCREATING RMAN CATALOG
• $ RMAN
• RMAN > Connect target sys/sys @con_tar
• RMAN > Connect catalog cat/cat @con_cat
• RMAN > Create catalog tablespace cat_tbs
• RMAN > Register database
![Page 17: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/17.jpg)
CONFIGURING RMAN FOR BACKUPCONFIGURING RMAN FOR BACKUP
![Page 18: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/18.jpg)
• RMAN> show all;• RMAN configuration parameters are:• CONFIGURE RETENTION POLICY TO REDUNDANCY 2;• CONFIGURE BACKUP OPTIMIZATION OFF; # default• CONFIGURE DEFAULT DEVICE TYPE TO DISK;• CONFIGURE CONTROLFILE AUTOBACKUP ON;• CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
DEVICE TYPE DISK TO '/%F;# default• CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default• CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE
TYPE DISK TO 1; # default• CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE
TYPE DISK TO 1; # default• CONFIGURE 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
![Page 19: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/19.jpg)
Various backup using RMANVarious backup using RMAN
Backing up Entire Database rman target sys/sys@con_tar catalog cat/cat@con_cat RMAN>backup database; (will backup data file , control file) Backing up the archived logs RMAN>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).
![Page 20: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/20.jpg)
Backing up tablespace
RMAN>backup tablespace <tbsname>; (will backup tablespace DB should
be in archivelogmode)
Backing up datafile: RMAN>backup datafile
‘<pathname>/<datafile name>’; It will backup datafile in Flash
Recovery Area/we can specify a path
![Page 21: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/21.jpg)
RESTORE
RESTORE
• Restore database - Restores entire database including controlfile
• Restore datafile <filename> - Restores specific datafiles
• Restore tablespace <tablespace_name> - Restores all details belongs to tablespace.
• Restore controlfile - Restores only controlfile• Restore archivelog all - Restores all
archivelog files.
![Page 22: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/22.jpg)
RECOVER RECOVER
Recover database - Recovering entire database Recover datafile <filename> - Recovering specific
datafiles Recover tablespace <tablespace_name> -
Recovering all datafiles belongs to the tablespaceRecover database until cancel - Recovering
database until cancelRecover database until time = <TIME> - Until timeRecover database until SCN = <SCN> - Until
Specific SCNRecover database until SEQUENCE =<SEQ> - Until
specific sequence
![Page 23: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/23.jpg)
SCENARIOS SCENARIOS
Scenario 1 - Recover full database Need to recover full database including controlfile, If we have
backup then we can start recovery. RMAN > Connect target sys/sys@con_tar RMAN > connect catalog cat/cat@con_cat RMAN > startup nomount RMAN > run { restore database; alter database mount; recover database; }
![Page 24: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/24.jpg)
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; }
![Page 25: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/25.jpg)
Scenario 3 - Recover lost datafileScenario 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;
}
![Page 26: Rman](https://reader035.fdocuments.in/reader035/viewer/2022062614/54647eeab4af9fd1478b4a54/html5/thumbnails/26.jpg)
Scenario 4 - Recover lost tablespace Scenario 4 - Recover lost tablespace
RMAN> run
{
alter tablespace sysaux offline
restore tablespace sysaux
recover tablespace sysaux
alter tablespace sysaux online
}