VRA Postgres Replication

If postgres replication is broken you may as well reset it up as opposed to trying to manually move the logs. Here’s how to do it

 

To set this up please follow https://kb.vmware.com/kb/2108923

/opt/vmware/vpostgres/current/share/show_replication_status
sync_priority | slave | sync_state | log_receive_position | log_replay_position | receive_delta | replay_delta
—————+——————–+————+———————-+———————+—————+————–
0 | bedtams520.dta.inf | async | 46/1994798 | 46/1994250 | 0 | 1352

If receive delta is 0 then replication is caught up.

You can also check the processes are running by

[on master] # ps -ef | grep sender
postgres 6879 6831 0 10:31 ? 00:00:00 postgres: wal sender process postgres 127.0.0.1(44663) streaming 0/2000000

[on standby] # ps -ef | grep receiver
postgres 6878 6872 1 10:31 ? 00:00:01 postgres: wal receiver process streaming 0/2000000

 

1. Clone master cloudvm.
2. start vmware-vpostgres on cloned vm as standalone instance, and write dummy record
3. stop vmware-vpostgres
4. write recovery.conf and start vmware-vpostgres
5. wait for pg_isready localhost to succeed
6.
SELECT status = ‘streaming’ AS is_streaming FROM pg_wal_receiver_state ;
is_streaming
————–
t

7. At this point
from the standby:
PGUSER=postgres /opt/vmware/vpostgres/current/scripts/show_replication_status
log_receive_position | log_replay_position | replay_delta
———————-+———————+————–
0/6000000 | 0/61FBC90 | -2079888

PGUSER=postgres /opt/vmware/vpostgres/current/scripts/show_replication_status
log_receive_position | log_replay_position | replay_delta
———————-+———————+————–
0/61FD658 | 0/61FBC90 | 6600

SELECT (status = ‘streaming’ and (received_up_to_lsn – receive_start_lsn) > 0) AS is_replicated FROM pg_wal_receiver_state;
If the result becomes NULL, the WAL receiver would be shut down. If it returns true, we are good to go

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s