Friday, September 12, 2014

Physical Standby is in out of sync

select name,open_mode,database_role from v$database;


select sequence#,client_process,process,status from v$managed_standby;

select sequence# from v$archived_log where applied='NO' and  sequence#>72533;

SELECT THREAD#, MAX(SEQUENCE#) AS "LAST_APPLIED_LOG" FROM V$LOG_HISTORY GROUP BY THREAD#;


SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received",
  2  APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
  3  FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE
  4  (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME)
  5  FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
  6  (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME )
  7  IN (SELECT THREAD#,MAX(FIRST_TIME)
  8  FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
  9  WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;

select to_char(current_scn,'9999999999999') from v$database;


SQL>   SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS
FROM V$MANAGED_STANDBY;
  2
PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH      CLOSING               1     133425       4096        313
ARCH      CLOSING               1     133423          1          5
ARCH      CONNECTED             0          0          0          0
ARCH      CLOSING               1     133424          1          1
MRP0      WAIT_FOR_GAP          1     133336          0          0
RFS       RECEIVING             1     133339       8193       2048
RFS       RECEIVING             1     133336       8193       2048
RFS       RECEIVING             1     133337       8193       2048



Step 1 :-

Take the current SCN from standby database .

SQL> select open_mode, database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
MOUNTED              PHYSICAL STANDBY

SQL> select to_char(current_scn,'9999999999999') from v$database;

TO_CHAR(CURREN
--------------
6031257396901


Step 2 :-

On the primary database create the needed incremental backup from the above SCN

$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Jun 15 16:37:20 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PSSM0S (DBID=2822979101)

RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 6031257396901 DATABASE FORMAT '/tmp/bkup_%U'  TAG 'FORSTANDBY';

Starting backup at 15-JUN-12

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 device type=DISK
backup will be obsolete on date 22-JUN-12
archived logs will not be kept or backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00008 name=/data_01/PSSM0S/tsd_sesame_data01.dbf
input datafile file number=00013 name=/dbs02/PSSM0S/tsd_sesame_data02.dbf
input datafile file number=00009 name=/data_02/PSSM0S/tsd_sesame_index01.dbf
input datafile file number=00011 name=/data_02/PSSM0S/TSD_SESAME_OLD_index01.dbf
input datafile file number=00005 name=/dbs02/PSSM0S/tools_std_tbl_01.dbf
input datafile file number=00007 name=/data_02/PSSM0S/tsd_audit_data01.dbf
input datafile file number=00003 name=/dbs01/PSSM0S/sysaux_tbl_01.dbf
channel ORA_DISK_1: starting piece 1 at 15-JUN-12
channel ORA_DISK_1: finished piece 1 at 15-JUN-12
piece handle=/tmp/bkup_llndk1qt_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/dbs01/PSSM0S/system_01.dbf
input datafile file number=00006 name=/data_01/PSSM0S/PSSM0W_tools_01.dbf
input datafile file number=00014 name=/dbs01/PSSM0S/undo_std_tbl_02.dbf
input datafile file number=00012 name=/data_01/PSSM0S/TSD_SESAME_OLD_data01.dbf
channel ORA_DISK_1: starting piece 1 at 15-JUN-12
channel ORA_DISK_1: finished piece 1 at 15-JUN-12
piece handle=/tmp/bkup_lmndk1u7_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/dbs02/PSSM0S/undo_std_tbl_01.dbf
input datafile file number=00004 name=/dbs01/PSSM0S/users_std_tbl_01.dbf
input datafile file number=00010 name=/data_01/PSSM0S/PSSM0W_users01.dbf
channel ORA_DISK_1: starting piece 1 at 15-JUN-12
channel ORA_DISK_1: finished piece 1 at 15-JUN-12
piece handle=/tmp/bkup_lnndk1vb_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

using channel ORA_DISK_1
backup will be obsolete on date 22-JUN-12
archived logs will not be kept or backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 15-JUN-12
channel ORA_DISK_1: finished piece 1 at 15-JUN-12
piece handle=/tmp/bkup_londk206_1_1 tag=FORSTANDBY comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-JUN-12


-rw-r-----   1 oracle   dba      2127740928 Jun 15 16:39 bkup_llndk1qt_1_1
-rw-r-----   1 oracle   dba      586907648 Jun 15 16:40 bkup_lmndk1u7_1_1
-rw-r-----   1 oracle   dba      1043472384 Jun 15 16:40 bkup_lnndk1vb_1_1
-rw-r-----   1 oracle   dba      26476544 Jun 15 16:40 bkup_londk206_1_1
PSSM0S @ gis2stl3:/tmp



Step 6 :-

Create new standby control file in the primary database

SQL> alter database create standby controlfile as '/tmp/standby_control.ctl';

Database altered.

Enter PASSCODE:
Enter PASSCODE:
bkup_llndk1qt_1_1                             100% 2029MB 369.9KB/s 1:33:38
/sys_apps_01/oem/TEMP/for_pssmow/bkup_llndk1qt_1_1: Disc quota exceeded
/sys_apps_01/oem/TEMP/for_pssmow/bkup_lmndk1u7_1_1: Disc quota exceeded
/sys_apps_01/oem/TEMP/for_pssmow/bkup_lnndk1vb_1_1: Disc quota exceeded
/sys_apps_01/oem/TEMP/for_pssmow/bkup_londk206_1_1: Disc quota exceeded


Enter PASSCODE:
bkup_llndk1qt_1_1                             100% 2029MB 388.2KB/s 1:29:13
/ora_exp_01/bkup_llndk1qt_1_1: Disc quota exceeded
/ora_exp_01/bkup_lmndk1u7_1_1: Disc quota exceeded
/ora_exp_01/bkup_lnndk1vb_1_1: Disc quota exceeded
/ora_exp_01/bkup_londk206_1_1: Disc quota exceeded
PSSM0W @ gis2woo2:/sys_apps_01/oem/TEMP/for_pssmow
$




Steps pending….

Step 3 :-

Cancel managed recovery at standby database.

SQL> alter database recover managed standby database cancel;

Database altered.


Step 4 :-

Copy the incremental backup sets from primary site to the standby location.

Step 5 :-

Catalog the copied backup files in the standby database

$ rman target / nocatalog

Recovery Manager: Release 10.2.0.4.0 - Production on Mon Apr 20 12:37:26 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: PSSM0S (DBID=2822979101, not open)
using target database control file instead of recovery catalog

RMAN> catalog start with '/sys_apps_01/oem/TEMP/for_pssmow';


Step 7:-

Connect to standby server  , CD to the location where incremental backup is copied from primary location.

Apply the incremental backup in the standby database. Please note that the location should be cataloged before proceeding this step.

RMAN> recover database noredo;


Step 8:-

Shutdown the standby database

$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Apr 20 13:32:19 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options

SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.


Step 9 :-

Take a copy of existing standby control file in standby site.. Copy the new control file which was created in the primary site to the standby location.

cp /oracle/admin/PSSM0W/pfile/standby_control.ctl .


Step 10 :-

Mount the standby database .

$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Apr 20 13:33:51 2009

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.


Step 11:-

Start the Managed recovery in the standby site and verify the log apply .



SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL> select process,sequence#,status from v$managed_standby
  2  /


SQL> select name,open_mode,database_role from v$database;
NAME      OPEN_MODE  DATABASE_ROLE
--------- ---------- ----------------
PGASP4    MOUNTED    PHYSICAL STANDBY
SQL> select process,status,sequence# from v$managed_standby;
PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
ARCH      CLOSING           51010
ARCH      CLOSING           50920
ARCH      CLOSING           51011
ARCH      CLOSING           50922
RFS       IDLE                  0
RFS       IDLE              51012
RFS       IDLE                  0
RFS       IDLE              51013
MRP0      APPLYING_LOG      51012
9 rows selected.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            f:\oracle\arch\pgasp4
Oldest online log sequence     51009
Next log sequence to archive   0
Current log sequence           51013
SQL> SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received",
  2  APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
  3  FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE
  4  (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME)
  5  FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
  6  (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME )
  7  IN (SELECT THREAD#,MAX(FIRST_TIME)
  8  FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
  9  WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;
    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                  51013                 51013          0


SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received",
APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE
(THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME)
FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
(SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME )
IN (SELECT THREAD#,MAX(FIRST_TIME)
FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;

SELECT DEST_ID, RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID=2;
2. select * from v$standby_log;

1. Please run the following on the primary:

select group#,type,member from v$logfile;
select group#,thread#,bytes,members,status from v$log;






No comments:

Post a Comment