Postgresql

Postgres 複製視圖

  • May 10, 2018

我看到 postgres 中的兩個視圖在複製和滯後時間方面存在一些差異。

通過此查詢,顯然複製已啟動:

9.5.6.11

postgres=# select client_addr, sent_location, replay_location from pg_stat_replication where application_name = 'walreceiver';
 client_addr   | sent_location | replay_location
----------------+---------------+-----------------
172.yyy.yyy.213  | 1C/2B5732F8   | 1C/2B5732F8
10.xxx.xxx.195 | 1C/2B5732F8   | 1C/2B5732F8
10.xxx.xxx.196 | 1C/2B5732F8   | 1C/2B5732F8

10.1

postgres=# select client_addr, sent_lsn, replay_lsn from pg_stat_replication where application_name = 'walreceiver';
client_addr  |  sent_lsn  | replay_lsn
--------------+------------+------------
10.qqq.qqq.44 | 1/8C000140 | 1/8C000140

但是當尋找滯後時間時:

9.5.6.11

postgres-# SELECT pg_last_xlog_receive_location() ,  pg_last_xlog_replay_location() ,  now() ,  pg_last_xact_replay_timestamp();
pg_last_xlog_receive_location | pg_last_xlog_replay_location |              now              | pg_last_xact_replay_timestamp
-------------------------------+------------------------------+-------------------------------+-------------------------------
                              |                              | 2018-05-10 04:19:38.079161-04 |

10.1

postgres=# SELECT pg_last_wal_receive_lsn() ,  pg_last_wal_replay_lsn() ,  now() ,  pg_last_xact_replay_timestamp();
pg_last_wal_receive_lsn | pg_last_wal_replay_lsn |              now              | pg_last_xact_replay_timestamp
-------------------------+------------------------+-------------------------------+-------------------------------
                        |                        | 2018-05-10 04:29:21.730089-04 |

沒有資訊..我錯過了什麼?

看起來您正在主伺服器上執行第二組查詢。這些功能需要在副本上執行,而不是在主伺服器上執行。

引用自:https://dba.stackexchange.com/questions/206330