Monday, July 4, 2011

Changing Backup Policy on Standby DB - 3

Previous two posts were using non-RAC data guard configurations. This blog used a RAC-RAC data guard configuration.

1. Requirment is to change the backup retention policy.
RMAN>
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name RAC11G2S are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of configure command at 04/07/2011 12:47:36
RMAN-05021: this configuration cannot be changed for a BACKUP or STANDBY control file
2. Change the backup retention policy on primary first
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
3. Make a standby controlfile on the primary after this can revert back to the earlier backup policy on primary.
RMAN> backup current controlfile for standby format '/tmp/standby.ctl';

Starting backup at 04-JUL-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 instance=rac11g21 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 04-JUL-11
channel ORA_DISK_1: finished piece 1 at 04-JUL-11
piece handle=/tmp/standby.ctl tag=TAG20110623T123939 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 04-JUL-11

Starting Control File and SPFILE Autobackup at 04-JUL-11
piece handle=+FLASH/rac11g2/autobackup/2011_07_04/s_754576786.494.754576789 comment=NONE
Finished Control File and SPFILE Autobackup at 04-JUL-11
4. Move the newly created standby controlfile on primary server to standby server.

5. Stop log apply and redo transport
DGMGRL> show configuration verbose

Configuration - rac11g2_dgb

Protection Mode: MaxPerformance
Databases:
rac11g2 - Primary database
rac11g2s - Physical standby database

DGMGRL> edit database rac11g2s set state='APPLY-OFF';
DGMGRL> edit database rac11g2 set state='TRANSPORT-OFF';
6. Shutdown all instances in standby database RAC and start one instance in nomount mode
srvctl stop database -d rac11g2s

SQL> startup nomount
ORACLE instance started.
7. Restore the controlfiles using the newly created standby controlfiles
RMAN> restore standby controlfile from '/home/oracle/standby.ctl';

Starting restore at 04-JUL-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=143 instance=rac11g2s2 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output file name=+DATA/rac11g2s/controlfile/current.257.754586439
output file name=+FLASH/rac11g2s/controlfile/current.482.754586439
8. Mount the database and catalog the datafiles
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> catalog start with '+DATA/rac11g2s/datafile';

Starting implicit crosscheck backup at 04-JUL-11
allocated channel: ORA_DISK_1
Crosschecked 8 objects
Finished implicit crosscheck backup at 04-JUL-11

Starting implicit crosscheck copy at 04-JUL-11
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 04-JUL-11

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: +flash/RAC11G2S/AUTOBACKUP/2011_07_04/s_755582799.520.755612793
File Name: +flash/RAC11G2S/AUTOBACKUP/2011_07_01/s_755372829.380.755372831
File Name: +flash/RAC11G2S/AUTOBACKUP/2011_07_01/s_755369531.371.755373091
File Name: +flash/RAC11G2S/BACKUPSET/2011_07_04/annnf0_TAG20110704T122511_0.435.755612715
File Name: +flash/RAC11G2S/BACKUPSET/2011_07_04/nnndf0_TAG20110704T122546_0.424.755612747
File Name: +flash/RAC11G2S/BACKUPSET/2011_07_01/annnf0_TAG20110701T174611_0.414.755372773
File Name: +flash/RAC11G2S/BACKUPSET/2011_07_01/nnndf0_TAG20110701T174616_0.387.755372777
File Name: +flash/RAC11G2S/BACKUPSET/2011_07_01/annnf0_TAG20110701T174706_0.478.755372827
File Name: +flash/RAC11G2S/BACKUPSET/2011_07_01/ncnnf0_TAG20110701T175126_0.315.755373087
File Name: +flash/RAC11G2S/ARCHIVELOG/2011_07_04/thread_1_seq_769.427.755612261

searching for all files that match the pattern +DATA/rac11g2s/datafile

List of Files Unknown to the Database
=====================================
File Name: +data/RAC11G2S/DATAFILE/SYSAUX.259.754586467
File Name: +data/RAC11G2S/DATAFILE/SYSTEM.258.754586581
File Name: +data/RAC11G2S/DATAFILE/UNDOTBS3.262.754586657
File Name: +data/RAC11G2S/DATAFILE/UNDOTBS2.261.754586713
File Name: +data/RAC11G2S/DATAFILE/USERS.276.754586727

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: +data/RAC11G2S/DATAFILE/SYSAUX.259.754586467
File Name: +data/RAC11G2S/DATAFILE/SYSTEM.258.754586581
File Name: +data/RAC11G2S/DATAFILE/UNDOTBS3.262.754586657
File Name: +data/RAC11G2S/DATAFILE/UNDOTBS2.261.754586713
File Name: +data/RAC11G2S/DATAFILE/USERS.276.754586727
9. Switch database to copy
RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DATA/rac11g2s/datafile/system.258.754586581"
datafile 2 switched to datafile copy "+DATA/rac11g2s/datafile/sysaux.259.754586467"
datafile 4 switched to datafile copy "+DATA/rac11g2s/datafile/users.276.754586727"
datafile 5 switched to datafile copy "+DATA/rac11g2s/datafile/undotbs2.261.754586713"
datafile 6 switched to datafile copy "+DATA/rac11g2s/datafile/undotbs3.262.754586657"
10. Clear the log files
SQL> select group# from v$log;

GROUP#
----------
1
2
3
4

alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database clear logfile group 4;
Generate the clearing SQL using and run the output
SQL> select 'alter database clear logfile group '||group#||';' from v$standby_log;
alter database clear logfile group 5;
alter database clear logfile group 6;
alter database clear logfile group 7;
alter database clear logfile group 8;
alter database clear logfile group 9;
alter database clear logfile group 10;
11. Shutdown the instance and start the RAC database
Database dismounted.
ORACLE instance shut down.

srvctl start database -d rac11g2s
12. Enable log apply and transport
dgmgrl sys/rac11g2db
Connected.

DGMGRL> edit database rac11g2s set STATE='APPLY-ON';
Succeeded.

DGMGRL> edit database rac11g2 SET STATE='TRANSPORT-ON';
Succeeded.
13. Verify log apply is working
SQL> select thread#,applied from v$archived_log;

THREAD# APPLIED
---------- ---------
1 YES
1 YES
1 IN-MEMORY
2 NO
2 YES
On primary do a log file archive
SQL> alter system archive log current;
and then on standby
THREAD# APPLIED
---------- ---------
1 YES
1 YES
1 YES
2 NO
2 YES
1 YES
2 YES
1 YES
2 IN-MEMORY
14. Verify that retention policy is changed
RMAN> show all

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name RAC11G2S are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
Once everything is confirmed to be working fine, remove the duplicate log files using asmcmd.