Skip to content

Commit c7d6764

Browse files
committed
added monitoring
1 parent e465ba6 commit c7d6764

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

replication.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,42 @@ restore_command = 'cp /path_to/archive/%f "%p"'
109109

110110
Start postgres in the standby server. It will start streaming replication.
111111

112+
113+
## How to Monitor Replication
114+
115+
On Master
116+
```
117+
select usename,application_name,client_addr,backend_start,state,sync_state from pg_stat_replication ;
118+
usename | application_name | client_addr | backend_start | state | sync_state
119+
------------+------------------+----------------+-------------------------------+-----------+------------
120+
replicator | walreceiver | 178.128.228.63 | 2020-06-02 00:45:54.011998+00 | streaming | async
121+
(1 row)
122+
```
123+
124+
On Slave
125+
126+
```
127+
postgres=# select * from pg_stat_wal_receiver;
128+
pid | status | receive_start_lsn | receive_start_tli | received_lsn | received_tli | last_msg_send_time | last_msg_receipt_time | latest_end_lsn | latest_end_time | slot_name | sender_host | sender_port |
129+
conninfo
130+
------+-----------+-------------------+-------------------+--------------+--------------+-------------------------------+-------------------------------+----------------+-------------------------------+-----------+---------------+-------------+----------------------------
131+
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
132+
1148 | streaming | 0/8000000 | 1 | 0/81BA090 | 1 | 2020-06-02 00:55:43.979656+00 | 2020-06-02 00:55:43.980689+00 | 0/81BA090 | 2020-06-02 00:50:13.266865+00 | | 165.227.44.48 | 5432 | user=replicator password=**
133+
****** dbname=replication host=165.227.44.48 port=5432 fallback_application_name=walreceiver sslmode=prefer sslcompression=0 gssencmode=prefer krbsrvname=postgres target_session_attrs=any
134+
(1 row)
135+
136+
```
137+
138+
112139
### How to do failover
113140

114141
Create the trigger file in the standby after the primary fails.
142+
115143
How to stop the primary or the standby server
144+
116145
Shut down it as usual (pg_ctl stop).
146+
117147
How to restart streaming replication after failover
118-
Repeat the operations from 6th; making a fresh backup, some configurations and starting the original primary as the standby. The primary server doesn't need to be stopped during these operations.
148+
149+
Repeat the operations from 6th; making a fresh backup, some configurations and starting the original primary as the standby. The primary server doesn't
150+
need to be stopped during these operations.

0 commit comments

Comments
 (0)