レプリケーション遅延監視

 

Data Guard Broker

dgmgrl

connect sys/oracle

show database verbose 'stb';

トランスポート・ラグや適用ラグを確認可能

 

-- RDSマニュアルに記載の方法
the sum of the Apply Lag value and the difference between the current time and the apply lag's DATUM_TIME value.
スタンバイで確認

select
to_dsinterval(value) + ( systimestamp - to_date(datum_time,'mm/dd/yyyy hh24:mi:ss')) lag
,value
,datum_time
,systimestamp
from v$dataguard_stats
where name = 'apply lag'
;

--pt-heartbeat
https://www.s-style.co.jp/products/percona/toolkit/pt-heartbeat

--ハートビートデーモン開始[マスター]
pt-heartbeat --create-table --database test --table heartbeat --update --daemonize

--監視テーブル確認[マスターとスレーブ]
select * from heartbeat;

--遅延の監視[スレーブ]
pt-heartbeat --database test --master-server-id 101 --monitor
pt-heartbeat --database test --master-server-id 101 --check

--ハートビートデーモン停止[マスター]
pt-heartbeat --database test --stop

→/tmp/pt-heartbeat-sentinelにファイルが作成される。
このファイルがあるとハートビートが動作しない。

 

-- RDSマニュアルに記載の方法
SHOW SLAVE STATUS コマンドの Seconds_Behind_Master フィールドの値
スタンバイで確認
show slave status\G

 

 


pt-heartbeatは動作確認不可


--マスタ側WAL位置
select pg_current_xlog_location();


--スタンバイ側WAL位置(マスタ側で確認)
select
state,
sent_location,
write_location,
flush_location,
replay_location
from pg_stat_replication;


--スタンバイ側WAL位置(スタンバイ側で確認)
select pg_last_xlog_receive_location();
select pg_last_xlog_replay_location();

 

 -- RDSマニュアルに記載の方法
スタンバイで確認
select extract(epoch from now() - pg_last_xact_replay_timestamp()) as slave_lag;

 

可用性グループダッシュボードで下記項目を確認可能
※明示的に表示列を追加する必要がある

最後にコミットしたLSN
最後に送信したLSN
最後に受信したLSN
最後に書き込まれたLSN

-- RDSマニュアルに記載の方法
プライマリで確認
select secondary_lag_seconds,*
from sys.dm_hadr_database_replica_states
;