查询归档历史:
SELECT FIRST_TIME,FIRST_CHANGE#,NEXT_CHANGE#, SEQUENCE# FROM V$LOG_HISTORY;
检查归档文件路径和创建信息
SELECT NAME,CREATOR,SEQUENCE#,APPLIED,COMPLETION_TIME FROM V$ARCHIVED_LOG;
查看进程的活动状态
V$MANAGED_STANDBY视图专用于显示物理Standby数据库相关进程的
当前状态,该视图中的列也很有特点,查看进程状态时,通常我们会关注
PROCESS、CLIENT_PROCESS、SEQUENC#和STATUS几列,例如:
SQL> SELECT PROCESS,CLIENT_PROCESS,SEQUENCE#, STATUS FROM V$MANAGED_STANDBY; PROCESS CLIENT_P SEQUENCE# STATUS --------- -------- ---------- ------------ ARCH ARCH 78 CLOSING ARCH ARCH 79 CLOSING MRP0 N/A 80 WAIT_FOR_LOG RFS LGWR 80 IDLE RFS ARCH 0 IDLE RFS N/A 0 IDLE
相关说明:
PROCESS:进程名称,如ARCH、RFS、MRP0等。
CLIENT_P:对应的Primary数据库中的进程,如ARCH、LGWR等。
SEQUENCE#:归档序号。
STATUS:进程的当前状态,值较多,常见的有:
1)ALLOCATED:正准备连接Primary数据库。
2)ATTACHED:正在连接Primary数据库。
3)CONNECTED:已连接至Primary数据库。
4)IDLE:空闲中。
5)RECEIVING:归档文件接收中。
6)OPENING:归档文件处理中。
7)CLOSING:归档文件处理完,收尾中。
8)WRITING:REDO数据库写向归档文件中。
9)WAIT_FOR_LOG:等待新的REDO数据中。
10)WAIT_FOR_GAP:归档有中断,正等待中断的那部分REDO数据。
11)APPLYING_LOG:应用REDO数据中。
查看最后应用的归档
SELECT THREAD#, MAX(SEQUENCE#) AS "LAST_APPLIED_LOG" FROM V$LOG_HISTORY GROUP BY THREAD#;
THREAD# LAST_APPLIED_LOG
---------- ----------------
1 3104
查看对应的应用状态
SELECT THREAD#, SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG;
THREAD# SEQUENCE# APPLIED
---------- ---------- ---------
1 3098 YES
1 3099 YES
1 3100 YES
1 3101 YES
1 3102 YES
1 3103 YES
1 3104 IN-MEMORY
查看物理Standby数据库未接收的日志文件
日志文件的发送是通过LOG_ARHIVE_DEST_N参数来控制,因此我们只需
要对比本地生成的归档和远端生成的归档间差异即可。例如:
select local.thread#, local.sequence# from (select thread#, sequence# from v$archived_log where dest_id=1) local where local.sequence# not in (select sequence# from v$archived_log where dest_id=2 and thread# = local.thread#);
THREAD# SEQUENCE#
---------- ----------
1 3098
1 3099
1 3100
1 3101
1 3102
1 3103
1 3104
监控日志应用服务
查询当前数据的基本信息(v$database信息)
select database_role,db_unique_name,open_mode,protection_mode,protection_level, switchover_status from v$database;
DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE
---------------- ------------------------------ --------------------
PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
-------------------- -------------------- --------------------
PHYSICAL STANDBY standby_oracle01 MOUNTED
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE NOT ALLOWED
查看当前REDO应用和REDO传输服务的活动状态
查询物理Standby 数据库当前REDO应用和REDO传输服务的状态非
V$MANAGED_STANDBY视图莫属,例如:
select process, status, thread#, sequence#, block#, blocks from v$managed_standby; PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS --------- ------------ ---------- ---------- ---------- ---------- ARCH CONNECTED 0 0 0 0 ARCH CONNECTED 0 0 0 0 ARCH CONNECTED 0 0 0 0 ARCH CLOSING 1 3104 6144 1008 ARCH CONNECTED 0 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 1 3105 1596 1 MRP0 APPLYING_LOG 1 3105 1596 163840
检查应用模式(是否启用了实时应用)
物理Standby数据库查询V$ARCHIVE_DEST_STATUS视图,如果打开了实
时应用,则RECOVERY_MODE列会显示为:MANAGED REAL TIME APPLY,
RECOVERY_MODE
-----------------------
IDLE
Data Guard事件(V$DATAGUARD_STATUS)
SQL> SELECT MESSAGE FROM V$DATAGUARD_STATUS;
MESSAGE
--------------------------------------------------------------------------------
ARC0: Archival started
ARC1: Archival started
ARC2: Archival started
ARC3: Archival started
ARC3: Becoming the 'no FAL' ARCH
ARC2: Becoming the heartbeat ARCH
ARC2: Becoming the active heartbeat ARCH
ARC4: Archival started
Managed Standby Recovery not using Real Time Apply
RFS[1]: Assigned to RFS process 27418
ARC3: Beginning to archive thread 1 sequence 3102 (14245665-14245874)
MESSAGE
--------------------------------------------------------------------------------
ARC3: Completed archiving thread 1 sequence 3102 (0-0)
Primary database is in MAXIMUM PERFORMANCE mode
RFS[2]: Assigned to RFS process 27420
Attempt to start background Managed Standby Recovery process
MRP0: Background Managed Standby Recovery process started
Managed Standby Recovery starting Real Time Apply
Clearing online redo logfile 1 /u01/app/oracle/oradata/oracle01/redo01.log
Clearing online redo logfile 1 complete
Clearing online redo logfile 2 /u01/app/oracle/oradata/oracle01/redo02.log
Clearing online redo logfile 2 complete
Clearing online redo logfile 3 /u01/app/oracle/oradata/oracle01/redo03.log
MESSAGE
--------------------------------------------------------------------------------
Clearing online redo logfile 3 complete
Clearing online redo logfile 9 /u01/app/oracle/oradata/oracle01/redo05a.log
Clearing online redo logfile 9 complete
Media Recovery Log /u01/app/oracle/product/11.2.0/db_1/dbs/archivelog/1_3102_100
0748999.dbf
Media Recovery Waiting for thread 1 sequence 3103 (in transit)
ARC3: Beginning to archive thread 1 sequence 3103 (14245874-14245930)
ARC3: Completed archiving thread 1 sequence 3103 (0-0)
Media Recovery Waiting for thread 1 sequence 3104 (in transit)
MRP0: Background Media Recovery cancelled with status 16037
MESSAGE
--------------------------------------------------------------------------------
Managed Standby Recovery not using Real Time Apply
MRP0: Background Media Recovery process shutdown
Managed Standby Recovery Canceled
Attempt to start background Managed Standby Recovery process
MRP0: Background Managed Standby Recovery process started
Managed Standby Recovery starting Real Time Apply
Media Recovery Waiting for thread 1 sequence 3104 (in transit)
ARC3: Beginning to archive thread 1 sequence 3104 (14245930-14250924)
ARC3: Completed archiving thread 1 sequence 3104 (0-0)
Media Recovery Waiting for thread 1 sequence 3105 (in transit)
41 rows selected.
设置RECOVER并行度
在介质恢复或REDO应用期间,都需要读取重做日志文件,默认都是串行
复,我们可以在执行RECOVER的时候加上PARALLEL子句来指定并行度,
高读取和应用的性能,例如:
SQL> RECOVER STANDBY DATABASE PARALLEL 2 ;
查看保护模式
SQL> select protection_mode,protection_level from v$database;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE