One way to check if logs get shipped and applied from primary to standby is by running the following query on both primary and standby databases:
On Standby:
Primary:
Connect to RMAN
Connect standby via RMAN and then connect to the catalog:
And finally run the following on the standby database via sqlplus:
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied" from (select thread# thrd, max(sequence#) almax from v$archived_log where resetlogs_change#=(select resetlogs_change# from v$database) group by thread#) al, (select thread# thrd, max(sequence#) lhmax from v$log_history where first_time=(select max(first_time) from v$log_history) group by thread#) lh where al.thrd = lh.thrd;If there is a discrepancy between primary and standby, one way to fix it is by rolling forward the physical standby using RMAN incremental backups of the primary. Here is a document on how to do that.
On Standby:
- Retrieve the current SCN number to be used for backing up database later on
SQL> SELECT to_char(current_scn, '999999999999999999') FROM V$DATABASE; TO_CHAR(CURRENT_SCN ------------------- XXXXXXXXXXX
- Cancel the managed recovery on standby
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Primary:
Connect to RMAN
rman RMAN> connect target / RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN XXXXXXXX DATABASE FORMAT '/tmp/DBNameStandby_%U' tag 'DBNAMESTANDBY';Standby:
Connect standby via RMAN and then connect to the catalog:
rman RMAN>connect target / RMAN>connect catalog username/pwd@catalogname RMAN>catalog start with '/tmp/DBNameStandby'; RMAN>REPORT SCHEMA; RMAN>STARTUP FORCE NOMOUNT; RMAN>RESTORE STANDBY CONTROLFILE FROM TAG 'DBNAMESTANDBY'; RMAN>ALTER DATABASE MOUNT; RMAN>RECOVER DATABASE NOREDO;If error occurs "ORA-19573: cannot obtain exclusive enqueue for datafile 5" when executing RECOVER DATABASE NOREDO; Run ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; via sqlplus on Standby
And finally run the following on the standby database via sqlplus:
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
No comments:
Post a Comment