Search This Blog

Total Pageviews

Saturday 19 December 2015

Oracle Standby out of Sync ..


Oracle Standby out of Sync ...

. Standby roll forward using RMAN incremental backup

How to Resolve Primary/Standby Log GAP In Case of Deleting Archivelogs From Primary?


On standby 

Identify the lowest  SCN on the Standby.. 

select MIN(scn) Min_Scn from (SELECT to_char(CURRENT_SCN) scn FROM V$DATABASE
                              union 
                              select to_char(min(fhscn)) from x$kcvfh
                              union 
                              select to_char(min(f.fhscn)) from x$kcvfh f, v$datafile d  
                              where f.hxfil =d.file#
                              and d.enabled != 'READ ONLY'
                              );


MIN_SCN
----------------------------------------
12066937215

Use this scn no to take backup on primary .

RMAN> BACKUP INCREMENTAL FROM SCN 12066937215 DATABASE FORMAT '/u01/rman_backup/stdby20140828/ForStandby_%U' tag 'FORSTANDBY';

RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/u01/rman_backup/stdby20140828/ForStandbyCTRL.bck';


cd /u01/rman_backup/

create scp script for copy file 
ls -1 *For* |awk '{print " scp -q "  $1 " " "akl0std:/u02/DISK_BACKUP/ &" }'

after copy the file 

On Standby ...

cancel the recovery ..


alter database recover managed standby database disconnectfrom session;
Database altered.

check for MRP0 process .. 
IMP  This process should not be running .

break on INST_ID
set pages 1000 lines 150
COL GROUP#    for a15
col status    for a20
select INST_ID,PROCESS,STATUS,SEQUENCE#,THREAD#,GROUP#,PID from gV$MANAGED_STANDBY 
order by INST_ID,STATUS;

on OS 
ps -ef|grep -i mrp 



RMAN> SHUTDOWN IMMEDIATE ;

RMAN> STARTUP NOMOUNT; 

RMAN> RESTORE STANDBY CONTROLFILE FROM '/u02/DISK_BACKUP/ForStandbyCTRL.bck'; 


Starting restore at 25-NOV-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=345 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/prod/control01.ctl
output file name=+DATA/prod/control02.ctl
Finished restore at 25-NOV-15

RMAN> shutdown;

database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

RMAN> CATALOG START WITH '/u02/DISK_BACKUP'; 

RMAN> RECOVER DATABASE NOREDO;

If there are datafiles created on the primary database after the last SCN on standby

SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > 12066937215;

Perform the switch so that the controlfile points to the datafiles under the standby directory.

RMAN> SWITCH DATABASE TO COPY;


To start recovery On standby !!!!

sqlplus 

alter database recover managed standby database using current logfile disconnect;


On Standby:
MRP identifier

break on INST_ID
set pages 1000 lines 150
COL GROUP#    for a15
col status    for a20
select INST_ID,PROCESS,STATUS,SEQUENCE#,THREAD#,GROUP#,PID from GV$MANAGED_STANDBY 
order by INST_ID,STATUS;



Metalink Note ..

standby database using RMAN Incremental Backup. (Doc ID 836986.1)
standby database using RMAN incremental backup when datafile is added to primary (Doc ID 1531031.1)  <<<<<<<

Imp part 

8) Rename the datafiles in new standby controlfile  !!!! if location different on Standby 

Since the controlfile is restored from PRIMARY the datafile locations in STANDBY controlfile will be same as PRIMARY database, so catalog datafiles in STANDBY will do the necessary rename operations.
Perform the below step  in STANDBY for each diskgroup where the datafile directory structure between primary and standby are different.

on standby 
RMAN> CATALOG START WITH '+DATA/<db_unqiue_name>/datafile/';

RMAN> SWITCH DATABASE TO COPY;
RMAN> RECOVER DATABASE NOREDO;



=======





Copy database file directly across network using RMAN in 11g including Primary and Standby (Doc ID 1909235.1)

rman target sys/<password>@<prmy_tns> auxiliary sys/<password>@<stby_tns>



run {
 allocate channel d1 type disk ;
 allocate channel d2 type disk ;
 backup as copy reuse
  datafile 4 auxiliary format '/u01/app/oracle/oradata/stby/users01.dbf'
   datafile 5 auxiliary format '/u01/app/oracle/oradata/stby/example01.dbf'
  ;
}

Oracle DBA

anuj blog Archive