有人可以建议检查pgsql复制状态的步骤以及何时说复制没有正确进行?
我们使用pgsql9.0和pgsql9.4的流式复制
感谢。
答案 0 :(得分:7)
在您的主服务器上,pg_stat_replication提供有关正在进行的复制的数据:
select client_addr, state, sent_location, write_location,
flush_location, replay_location from pg_stat_replication;
在postgresql v10上:
select client_addr, state, sent_lsn, write_lsn,
flush_lsn, replay_lsn from pg_stat_replication;
答案 1 :(得分:4)
在PostgreSQL中显示复制状态
postgres=# select usename,application_name,client_addr,backend_start,state,sync_state from pg_stat_replication ;
usename | application_name | client_addr | backend_start | state | sync_state
------------+------------------+----------------+-------------------------------+-----------+------------
replicator | walreceiver | 192.168.10.132 | 2018-07-06 06:12:20.786918+03 | streaming | async
(1 row)
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)
postgres=# select pg_last_xlog_receive_location();
pg_last_xlog_receive_location
-------------------------------
0/540C1DB8
postgres=# select pg_last_xlog_replay_location();
pg_last_xlog_replay_location
------------------------------
0/540C1DB8
(1 row)
postgres=# SELECT CASE WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location()
THEN 0
ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp())
END AS log_delay;
log_delay
-----------
0
(1 row)
答案 2 :(得分:2)
我通常使用以下SQL查询来检查Postgres v11的状态。
在母版上:
select * from pg_stat_replication;
在副本上(在我的情况下为流复制):
select * from pg_stat_wal_receiver;