PostgreSQL
Replication Commands
Replication & HA
5 commands
Commands
Replication status
$ SELECT * FROM pg_stat_replication;
Monitor replication status and lag.
Check if replica
$ SELECT pg_is_in_recovery();
Check if server is in recovery (replica) mode.
Stream WAL logs
$ pg_receivewal -D /wal/archive --slot slot_name
Stream WAL logs to archive directory.
View replication slots
$ SELECT * FROM pg_replication_slots;
List all replication slots and their status.
Create logical publication
$ CREATE PUBLICATION my_pub FOR TABLE users;
Create publication for logical replication.