rman
Post on 13-Nov-2014
18 Views
Preview:
DESCRIPTION
TRANSCRIPT
Backup & Recovery (Oracle 10g) - RMANBackup & Recovery (Oracle 10g) - RMAN
Sandeep Kumar Sinha Sembiyan.V
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
• 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.
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.
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
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;
Example of cumulative incremental backup Example of cumulative incremental backup
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;
Example of differential incremental backup Example of differential incremental backup
STARTING WITH RMANSTARTING WITH RMAN
• Connect to target database
• Create listener
• Create connection descriptor
• Start listener
• Ping
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
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
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
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
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)
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
CONFIGURING RMAN FOR BACKUPCONFIGURING RMAN FOR BACKUP
• 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
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).
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
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.
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
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; }
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 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;
}
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
}
THANK YOU
Sandeep kumar Sinha Sembiyan.v Email – sandeepsinhaextc@gmail.com v.sembiyan@gmail.com
top related