Monday 23 July 2012

Backup Scenario's on (Physical Standby )



* This paper outlines RMAN procedures to setup and backup physical standby databases managed by Data Guard in an Oracle Database 10g environment.
   Note that only backups from a physical standby database can be used to recover the primary database.

The procedures outlined include:
• Configuring RMAN persistent settings on primary and standby databases.
• Creating database backups at the standby database that can be used to recover the primary or standby database.
• Recovering data files on the primary or standby database using backups that are made on the standby database.

RMAN brings rich functionality such as
• online backups.
• incremental backups.
• block media recovery.
• automation of backup management tasks.
• integration with 3rd party media management systems into the Data Guard configuration.

RMAN backups can be seamlessly offloaded to a physical standby database, allowing customers to gain more value out of
their disaster recovery investment. Backups do not impact normal Data Guard operation – they can be taken while the standby
database is in recovery or read-only mode.Backups can be used to recover either primary or standby database servers.

The following sections cover:
• RMAN and Data Guard configuration settings
• Backup procedures for primary and standby, to disk and tape
• Recovery scenarios on primary and standby
• RMAN-based instantiation of standby database


SETUP ASSUMPTIONS
The assumptions for this setup are:
Using Recovery Manager with Oracle Data Guard in Oracle Database 10g Page 5
• The standby database is a physical standby database and backups are only taken on the standby database. Refer to the Appendix for procedural
   changes if backups are taken on both primary and standby databases.
• The data file directories on the primary and standby database are identical.
  This simplifies the RMAN backup and recovery operations no matter which host is used.
• RMAN Recovery Catalog is required so that backups taken on one database server can be restored onto another database server.
   Using just the control file as the RMAN repository is not sufficient, as the primary database will have no knowledge of backups
    taken on the standby database.
The RMAN Recovery Catalog organizes backup histories and other recovery-related metadata in a centralized location.
The recovery catalog is configured in a database and maintains backup metadata. A recovery catalog does not have the space limitations
of the control file and can store more historical data about backups.
A catalog server, physically separate from the primary and standby sites, is recommended in a Data Guard configuration
as disaster striking either site will not affect the ability to recover the latest backups.

• All databases in the configuration use Oracle Database 10g Release 1 or Release 2.
• Primary database does not use Oracle Managed Files (OMF). When using OMF, standby database filenames can vary from those on the primary. Refer to the Appendix for modifications to the restore procedures when standby database filenames are different than those on the primary.
• 3rd party media management software is configured with RMAN to make backups to tape.

Note: The Appendix describes modifications to these procedures for three alternate configurations:
• Backups are made at both the primary and standby database sites due to the inability to access the backup from the originating host
• Standby database is configured as an archived log repository
• Standby database file names are different than those on the primary




Creat All database on different servers  ----that's recommended

1.PRIMAY DATABASE
2.STANDBY DATABASE
3.CATALOG DATABASE
Backup Strategy On Physical standby database scenario.

----SQL
Work some objects on primary database site
create table abc
update same table
switch  logfile 2,3 time
select * from abc;
select sequence#,applied from v$archived_log order by 1;

-----STANDBY
SQL> ALTER DATABASE [ENABLE|DISABLE] BLOCK CHANGE TRACKING
SQL> select filename, status, bytes from v$block_change_tracking;
SQL> select file#, avg(datafile_blocks) blocks,
avg(blocks_read) blocks_read,
avg(blocks_read/datafile_blocks)*100 pct_read,
avg(blocks) blocks_backed_up
from v$backup_datafile
where used_change_tracking = 'YES'
and incremental_level = 1
group by file#
order by file#;


-----Primary
connect through recovery catalog

Register Database;
configure archivelog deletion policy to shipped to all standby;
configure archivelog deletion policy to applied to standby;
configure retention policy to recovery window of 7 days;
configure db_unique_name orcl connect identifier 'orcl';
configure db_unique_name pune connect identifier 'pune';
list db_unique_name of database;



-----Standby
connect through recovery catalog

Register database;
configure archivelog deletion policy to applied to standby;
configure archivelog deletion policy to backed up 1 times on disk;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\Backup\CTL_%F';
configure controlfile autobackup on;
configure backup optimization on;
configure channel device type disk format 'D:\Backup\%d_%u';
configure deletion policy to none;




----Backup Physical Standby
connect through recovery catalog

RECOVER COPY OF DATABASE WITH TAG 'FULL';
BACKUP  INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'FULL' DATABASE;
BACKUP ARCHIVELOG ALL FILESPERSET 100 TAG='ARCH';
BACKUP BACKUPSET ALL;





----SQL
Work some objects on primary database site
create table cde
update same table
select * from cde;
select sequence#,applied from v$archived_log order by 1;




----Backup Physical Standby
RECOVER COPY OF DATABASE WITH TAG 'FULL';
BACKUP  INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'FULL' DATABASE;
BACKUP ARCHIVELOG ALL FILESPERSET 100 TAG='ARCH';
BACKUP BACKUPSET ALL;



##When lost the datafile on PRIMARY database then Recover to Physical Standby database backup.


C:\>rman target=sys@pune

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 12 14:01:21 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (DBID=1313471048)

RMAN> connect auxiliary sys@orcl
connected to auxiliary database: ORCL (DBID=1313471048, not open)

RMAN> BACKUP AS COPY FORCE DATAFILE 4 AUXILIARY FORMAT 'D:\app\administrator\oradata\orcl\user01.dbf';

Starting backup at 12-JUL-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=C:\PUNE\USERS01.DBF
output file name=D:\APP\ADMINISTRATOR\ORADATA\ORCL\USER01.DBF tag=TAG20120712T140233
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
Finished backup at 12-JUL-12


RMAN> exit
Recovery Manager complete.


C:\>rman target=sys@orcl
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 12 14:04:28 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: ORCL (DBID=1313471048, not open)

RMAN> connect catalog rman@cat
connected to recovery catalog database

RMAN> catalog datafilecopy 'D:\app\administrator\oradata\orcl\user01.dbf';

cataloged datafile copy
datafile copy file name=D:\APP\ADMINISTRATOR\ORADATA\ORCL\USER01.DBF RECID=2 STAMP=788450751

RMAN> run{
2> sql 'alter database datafile 4 offline';
3> set newname for datafile 4 to 'D:\app\administrator\oradata\orcl\user01.dbf';
4> switch datafile 4;
5> recover datafile 4;
6> sql 'alter database datafile 4 online';
7> }

sql statement: alter database datafile 4 offline

executing command: SET NEWNAME

datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=788450751 file name=D:\APP\ADMINISTRATOR\ORADATA\ORCL\USER01.DBF
starting full resync of recovery catalog
full resync complete

RMAN> exit
Recovery Manager complete.

C:\> sqlplus sys@orcl as sysdba
SQL> set line 32000
SQL> select * from v$datafile; //check the datafile status is online & offline mode.



========================================================================
## Resync backup Physical Standby to PRIMARY database backup catalog.


----standby database take a backup
backup database plus archivelog;


----primary get physical standby backup information
catalog start with '/u02/Backup/';




========================================================================
##Question.
My question is when i have try to take a backup with recovery catalog on standby side it's auto resync the 
backup information on primary database recover catalog or not .If yes so how we are resync or scenario. 

No comments: