赞
踩
查看复制延迟:
10.0及以上:
- SELECT
- pg_wal_lsn_diff(A .c1, replay_lsn) /(1024 * 1024) AS slave_latency_MB,
- pg_wal_lsn_diff(A .c1, sent_lsn) /(1024 * 1024) AS send_latency_MB,
- pg_wal_lsn_diff(A .c1, flush_lsn) /(1024 * 1024) AS flush_latency_MB,
- state,
- backend_start,
- now()::timestamp with time zone
- FROM pg_stat_replication, pg_current_wal_lsn() AS A(c1)
- WHERE client_addr='192.168.46.173' and application_name = 'standby1'
- ORDER BY slave_latency_MB, send_latency_MB DESC
- LIMIT 1;
注:
192.168.46.173 表示从库ip地址。
pg_wal_lsn_diff(lsn
pg_lsn
, lsn
pg_lsn
):计算两个预写式日志位置间的差别。
pg_current_wal_lsn():获得当前预写式日志写入位置
小于10.0版本:
- SELECT
- pg_xlog_location_diff(A .c1, replay_lsn) /(1024 * 1024) AS slave_latency_MB,
- pg_xlog_location_diff(A .c1, sent_lsn) /(1024 * 1024) AS send_latency_MB,
- pg_xlog_location_diff(A .c1, flush_lsn) /(1024 * 1024) AS flush_latency_MB,
- state,
- backend_start,
- now()::timestamp with time zone
- FROM pg_stat_replication, pg_current_xlog_location AS A(c1)
- WHERE client_addr='192.168.46.173' and application_name = 'standby1'
- ORDER BY slave_latency_MB, send_latency_MB DESC
- LIMIT 1;
注:
192.168.46.173 表示从库ip地址。
pg_xlog_location_diff(lsn
pg_lsn
, lsn
pg_lsn
):计算两个预写式日志位置间的差别。
pg_current_xlog_location ():获得当前预写式日志写入位置
大量数据导入和从库备份导致了大量的主从延迟,延迟的wal日志超过wal_keep_segments
造成了主库上的xlog目录被清理,从库需要的日志被清理掉了,最终复制中断。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。