在做流复制的时候,注意Replication Slots的使用,主要的作用是避免备库未应用的wal日志被remove掉:
Replication slots provide an automated way to ensure that the master does not remove WAL segments until they have been received by all standbys, and that the master does not remove rows which could cause a recovery conflict even when the standby is disconnected.
https://www.postgresql.org/docs/9.5/static/warm-standby.html#STREAMING-REPLICATION-SLOTS
关于slots的其他作用也可参照以上链接。
配置前需修改参数max_replication_slots大于0:
highgo=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
ERROR: 55000: replication slots can only be used if max_replication_slots > 0
配置示例:
You can create a replication slot like this:
postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
slot_name | xlog_position
-------------+---------------
node_a_slot |
postgres=# SELECT * FROM pg_replication_slots;
slot
Replication slots provide an automated way to ensure that the master does not remove WAL segments until they have been received by all standbys, and that the master does not remove rows which could cause a recovery conflict even when the standby is disconnected.
https://www.postgresql.org/docs/9.5/static/warm-standby.html#STREAMING-REPLICATION-SLOTS
关于slots的其他作用也可参照以上链接。
配置前需修改参数max_replication_slots大于0:
highgo=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
ERROR: 55000: replication slots can only be used if max_replication_slots > 0
配置示例:
You can create a replication slot like this:
postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
slot_name | xlog_position
-------------+---------------
node_a_slot |
postgres=# SELECT * FROM pg_replication_slots;
slot

本文介绍了PostgreSQL流复制中Replication Slots的重要作用,防止主库在备库未应用WAL日志时将其删除。通过创建和配置Replication Slots,确保主备数据一致性。同时提到了配置Replication Slots的步骤,包括修改max_replication_slots参数,创建slot以及在备库的recovery.conf中设置primary_slot_name。
最低0.47元/天 解锁文章
564

被折叠的 条评论
为什么被折叠?



