流复制Replication Slots的使用--防止主端未应用的WAL被删除

本文介绍了PostgreSQL流复制中Replication Slots的重要作用,防止主库在备库未应用WAL日志时将其删除。通过创建和配置Replication Slots,确保主备数据一致性。同时提到了配置Replication Slots的步骤,包括修改max_replication_slots参数,创建slot以及在备库的recovery.conf中设置primary_slot_name。
摘要由CSDN通过智能技术生成
在做流复制的时候,注意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
-------------+---------------
 nod
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值