0% found this document useful (0 votes)
10 views

oracle 11 2 dataguard监控sql

Uploaded by

yk59465258
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

oracle 11 2 dataguard监控sql

Uploaded by

yk59465258
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

oracle 11.

2 DataGuard 监控 SQL

datagaurd 数据库 alert 日志


view /u01/app/oracle/diag/rdbms/standby/standby/trace/alert_standby.log

查看 datagaurd 主机文件系统使用情况(必需看)
[root@jymesdg ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 44G 18G 24G 44% /
tmpfs 16G 292K 16G 1% /dev/shm
/dev/sda1 194M 34M 151M 19% /boot
/dev/sdb1 197G 95G 93G 51% /oradata
/dev/sdc1 99G 1.7G 92G 2% /archivelog

备用数据库查询重做数据传输和应用滞后(必需看)

SQL> set linesize 150;


set pagesize 20;
column name format a13;
column value format a20;
column unit format a30;
column TIME_COMPUTED format a30;
select name,value,unit,time_computed from v$dataguard_stats where name in ('transport lag','apply lag');

NAME VALUE UNIT TIME_COMPUTED


------------- -------------------- ------------------------------ ------------------------------
transport lag +00 00:00:00 day(2) to second(0) interval 06/17/2014 08:35:23
apply lag +00 00:00:00 day(2) to second(0) interval 06/17/2014 08:35:23

其中:"transport lag"的值表示主数据库到物理备库的重做数据传输落后时间,这里落后 3 秒。如果主数据库发生灾难,就要容忍损失 3 秒的数据。或者,如果想要执行切换,必须等到 3 秒。


"apply lag"的值表示应用重做数据时间,这里落后 6 秒。

备用数据库查询 V$MANAGED_STANDBY 视图验证重做状态(必需看)

SQL> set linesize 150;


set pagesize 200;
column PROCESS format a7;
column STATUS format a15;
column client_pid format a12;
column CLIENT_PROCESS format a12;
select pid,process,status,client_process,client_pid,
thread#,sequence# seq#,block#,blocks
from v$managed_standby;

PID PROCESS STATUS CLIENT_PROCE CLIENT_PID THREAD# SEQ# BLOCK# BLOCKS


---------- ------- --------------- ------------ ------------ ---------- ---------- ---------- ----------
22764 ARCH CLOSING ARCH 22764 1 21 12288 902
22766 ARCH CONNECTED ARCH 22766 0 0 0 0
22768 ARCH CLOSING ARCH 22768 1 20 1 313
22770 ARCH CLOSING ARCH 22770 2 20 1 1
22772 ARCH CLOSING ARCH 22772 2 21 1 125
23396 RFS IDLE ARCH 31526 0 0 0 0
23383 RFS IDLE UNKNOWN 31536 0 0 0 0
23385 RFS IDLE UNKNOWN 31518 0 0 0 0
23392 RFS IDLE UNKNOWN 31530 0 0 0 0
23390 RFS IDLE LGWR 31544 1 22 274870 1
23418 RFS IDLE ARCH 22273 0 0 0 0
22914 MRP0 APPLYING_LOG N/A N/A 1 22 274870 1048576
23410 RFS IDLE UNKNOWN 22275 0 0 0 0

Beijing ChinaITsoft-ITS Technology CO.,LTD WebSite: www.ChinaITsoft.com


23412 RFS IDLE UNKNOWN 22201 0 0 0 0
23414 RFS IDLE LGWR 22287 2 22 104671 1

15 rows selected.
注:表明主数据库正在发送 1 号线程 22 号序列的重做日志。
MRP0 进程的状态不要出现 WAIT_FOR_GAP 的情况,如果出现,要检查原因并及时处理。

主备数据库查询 V$ARCHIVE_GAP 视图监控重做日志间隔(必需看)

SQL> select INST_ID,THREAD#,LOW_SEQUENCE#,HIGH_SEQUENCE# from gv$archive_gap;

no rows selected

注:正常情况下不会有返回结果。如果出现要及时处理。

主数据库中查询 V$LOG 视图,确认重做日志序列号(必需看)

SQL> select GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS from v$log;

GROUP# THREAD# SEQUENCE# ARC STATUS


---------- ---------- ---------- --- ----------------
1 1 21 YES INACTIVE
2 1 22 NO CURRENT
3 1 19 YES INACTIVE
4 1 20 YES INACTIVE
5 2 21 YES INACTIVE
6 2 22 NO CURRENT
7 2 19 YES INACTIVE
8 2 20 YES INACTIVE

8 rows selected.

注意:备库正在应用的重做日志线程号和序列号差距不能过大。差距越大,延迟越大。

主备数据库查询 V$ARCHIVED_LOG 视图比较最大序列号确定重做传输延迟

SQL> alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';


select distinct RESETLOGS_TIME,RESETLOGS_ID from v$archived_log;

RESETLOGS_TIME RESETLOGS_ID
------------------- ------------
2014-06-16 08:53:39 850380819

SQL> select THREAD#,max(SEQUENCE#) from v$archived_log where RESETLOGS_ID='850380819' group by thread#;

THREAD# MAX(SEQUENCE#)
---------- --------------
1 21
2 21

注:每个线程的最大序列号不要出现很大的偏移量。

Beijing ChinaITsoft-ITS Technology CO.,LTD WebSite: www.ChinaITsoft.com


主数据库查询尚未到达备用数据库目的地的归档日志

SQL> select l.THREAD#,l.SEQUENCE#


from (select THREAD#,SEQUENCE# from v$archived_log where dest_id=1) l
where l.SEQUENCE# not in (select SEQUENCE# from v$archived_log where dest_id=2 and THREAD#=l.THREAD#)
order by 1,2;

no rows selected

注:正常情况下不会有返回结果。如果出现表明传输重做日志有延迟,要及时处理。

备用数据库查询 V$RECOVERY_PROGRESS 视图检查重做日志应用率和活动率

SQL> set linesize 150;


column START_TIME format a20;
column ITEM format a20;
select to_char(START_TIME,'YYYY-MM-DD HH24:MI:SS') START_TIME,ITEM,SOFAR
from v$recovery_progress
where item in('Active Apply Rate','Average Apply Rate','Redo Applied');

START_TIME ITEM SOFAR


-------------------- -------------------- ----------
2014-06-16 21:40:50 Active Apply Rate 766
2014-06-16 21:40:50 Average Apply Rate 36
2014-06-16 21:40:50 Redo Applied 1400

备用数据库查询 V$DATAGAURD_STATUS 视图

V$DATAGAURD_STATUS 视图标识了将错误信息写到警报日志文件和/或生成与错误有关的跟踪文件的事件。
SQL> set linesize 150;
set pagesize 100;
column SEVERITY format a13;
column message format a70;
column timestamp format a20;
select error_code,severity,message,to_char(timestamp,'YYYY-MM-DD HH24:MI:SS') TIMESTAMP from v$dataguard_status
where callout='YES' and timestamp >sysdate-1;

ERROR_CODE SEVERITY MESSAGE TIMESTAMP


---------- ------------- ---------------------------------------------------------------------- --------------------
0 Control Media Recovery Complete 2014-06-16 21:24:12
0 Control Attempt to start background Managed Standby Recovery process 2014-06-16 21:40:45
0 Control MRP0: Background Managed Standby Recovery process started 2014-06-16 21:40:46
0 Control ARC2: Beginning to archive thread 1 sequence 17 (1408809-1554845) 2014-06-16 22:06:15
0 Control ARC2: Completed archiving thread 1 sequence 17 (0-0) 2014-06-16 22:06:29
0 Control ARC4: Beginning to archive thread 1 sequence 18 (1554845-1683022) 2014-06-16 22:12:03
0 Control ARC4: Completed archiving thread 1 sequence 18 (0-0) 2014-06-16 22:12:06
0 Control ARC2: Beginning to archive thread 1 sequence 19 (1683022-1805154) 2014-06-16 23:34:50
0 Control ARC2: Completed archiving thread 1 sequence 19 (0-0) 2014-06-16 23:34:50
0 Control ARC3: Beginning to archive thread 2 sequence 18 (1408812-1805152) 2014-06-16 23:34:51
0 Control ARC3: Completed archiving thread 2 sequence 18 (0-0) 2014-06-16 23:34:52
0 Control ARC2: Beginning to archive thread 1 sequence 20 (1805154-1805697) 2014-06-16 23:34:54
0 Control ARC2: Completed archiving thread 1 sequence 20 (0-0) 2014-06-16 23:34:54
0 Control ARC3: Beginning to archive thread 2 sequence 20 (1807823-1807828) 2014-06-16 23:36:43
0 Control ARC3: Completed archiving thread 2 sequence 20 (0-0) 2014-06-16 23:36:43
0 Control ARC4: Beginning to archive thread 2 sequence 21 (1807828-1808639) 2014-06-16 23:36:45
0 Control ARC4: Completed archiving thread 2 sequence 21 (0-0) 2014-06-16 23:36:45
0 Control ARC0: Beginning to archive thread 1 sequence 21 (1805697-1810066) 2014-06-16 23:36:48
0 Control ARC0: Completed archiving thread 1 sequence 21 (0-0) 2014-06-16 23:36:48

19 rows selected.

Beijing ChinaITsoft-ITS Technology CO.,LTD WebSite: www.ChinaITsoft.com


备用数据库查询 V$STANDBY_LOG 视图确定接收到的最后 SCN

SQL> set linesize 150;


alter session set nls_date_format="YYYY-MM-DD HH24:MI:SS";
select thread#,sequence#,last_change#,last_time from v$standby_log;

THREAD# SEQUENCE# LAST_CHANGE# LAST_TIME


---------- ---------- ------------ -------------------
1 0
1 22 1952252 2014-06-17 08:36:55
1 0
1 0
1 0
2 0
2 22 1952250 2014-06-17 08:36:55
2 0
2 0
2 0

10 rows selected.

备库查询归档日志应用情况

SQL> set pagesize 200;


alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
SELECT THREAD#,APPLIED,SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

THREAD# APPLIED SEQUENCE# FIRST_TIME NEXT_TIME


---------- --------- ---------- ------------------- -------------------
1 YES 11 2014-06-16 12:26:23 2014-06-16 20:40:59
1 YES 12 2014-06-16 20:40:59 2014-06-16 20:41:04
2 YES 12 2014-06-16 12:26:23 2014-06-16 20:41:01
1 YES 13 2014-06-16 20:41:04 2014-06-16 20:41:07
2 YES 13 2014-06-16 20:41:01 2014-06-16 20:41:04
2 YES 14 2014-06-16 20:41:04 2014-06-16 20:41:10
1 YES 14 2014-06-16 20:41:07 2014-06-16 20:41:16
2 YES 15 2014-06-16 20:41:10 2014-06-16 20:41:13
1 YES 15 2014-06-16 20:41:16 2014-06-16 21:09:50
2 YES 16 2014-06-16 20:41:13 2014-06-16 21:09:49
1 YES 16 2014-06-16 21:09:50 2014-06-16 21:44:29
2 YES 17 2014-06-16 21:09:49 2014-06-16 21:44:29
1 YES 17 2014-06-16 21:44:29 2014-06-16 22:06:37
1 YES 18 2014-06-16 22:06:37 2014-06-16 22:12:25
2 YES 18 2014-06-16 21:44:29 2014-06-16 23:35:10
2 YES 19 2014-06-16 23:35:10 2014-06-16 23:35:13
1 YES 19 2014-06-16 22:12:25 2014-06-16 23:35:10
1 YES 20 2014-06-16 23:35:10 2014-06-16 23:35:16
2 YES 20 2014-06-16 23:37:04 2014-06-16 23:37:04
1 IN-MEMORY 21 2014-06-16 23:35:16 2014-06-16 23:37:10
2 YES 21 2014-06-16 23:37:04 2014-06-16 23:37:07

21 rows selected.

Beijing ChinaITsoft-ITS Technology CO.,LTD WebSite: www.ChinaITsoft.com

You might also like