官术网_书友最值得收藏!

Time for action – verifying synchronization between the primary and standby databases

By using the following steps, you can control whether the standby database is synchronized with primary:

  1. On the standby database, query the V$ARCHIVED_LOG view for the archived and applied sequences.

    For the last archived sequence, use the following:

    SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;
    MAX(SEQUENCE#)
    --------------
     145
    

    For the last applied sequence, use the following:

    SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG WHERE APPLIED='YES';
    MAX(SEQUENCE#)
    --------------
     144
    

    From the preceding two queries, we see that the latest sequence, 145, is being archived or written into the standby redo logfiles. There's expected to be a lag of one sequence between archived and applied columns.

  2. Check the status of the latest log sequence.
    SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
    
     SEQUENCE# APPLIED
    ---------- ---------
     140 YES
     141 YES
     142 YES
     143 YES
     144 YES
     145 IN-MEMORY
    

    The log sequence 145 is still being shipped.

  3. On the primary database query for the last archived logfile, perform a couple of log switches and then monitor if those archives are transported and applied.
    SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;
    MAX(SEQUENCE#)
    --------------
     145
    

    Perform log switches several times and check.

    SQL> alter system switch logfile;
    System altered.
    
    SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;
    MAX(SEQUENCE#)
    --------------
     148
    
  4. On the standby query for new archived logfiles and applied archived logfiles, query if the new archive log sequences are applied on standby.
    SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
     SEQUENCE# APPLIED
    ---------- ---------
     143 YES
     144 YES
     145 YES
     146 YES
     147 YES
     148 YES
    

    The APPLIED column on standby will be very helpful to determine which sequence is generated and which sequences are applied. In the previous scenario, the archives generated on primary and archives applied on standby have the same sequence number; hence, standby is synchronized with the primary database.

    The value of the APPLIED column for the most recently received logfile will be IN-MEMORY, or YES if that logfile has been applied.

What just happened?

It's very important to know methods to verify synchronization between primary and standby databases. We've now seen one of these methods.

主站蜘蛛池模板: 梅州市| 荔波县| 永年县| 化州市| 确山县| 石城县| 莆田市| 峨边| 谢通门县| 江川县| 成武县| 托克托县| 玉田县| 乐昌市| 邢台市| 峡江县| 金门县| 宁晋县| 屯门区| 扶绥县| 江津市| 静海县| 唐河县| 文登市| 玛多县| 上犹县| 佛山市| 九寨沟县| 大厂| 北川| 赞皇县| 沙河市| 台北市| 红桥区| 黑山县| 鄂托克前旗| 资源县| 邻水| 合江县| 赣州市| 五常市|