digoal
2019-06-15
PostgreSQL , 逻辑订阅 , 逻辑复制
PostgreSQL 同一实例(集群)的不同数据库之间,例如A库有一个表TBL要增量同步到B库的TBL,有什么方法?
逻辑订阅。但是需要注意:
https://www.postgresql.org/docs/12/sql-createsubscription.html
Creating a subscription that connects to the same database cluster
(for example, to replicate between databases in the same cluster or to replicate within the same database) will only succeed if the replication slot is not created as part of the same command.
Otherwise, the CREATE SUBSCRIPTION call will hang.
To make this work, create the replication slot separately (using the function pg_create_logical_replication_slot with the plugin name pgoutput)
and create the subscription using the parameter create_slot = false.
This is an implementation restriction that might be lifted in a future release.
在B库创建sub时,不要自动创建SLOT,否则会HANG住。以上是文档中的说明。
未来的版本会改进。
https://www.postgresql.org/docs/12/sql-createsubscription.html
《PostgreSQL 暂时不支持replication slot信息的主从同步》
《PostgreSQL 12 preview - 支持replica slot复制(copy slot)》
《PostgreSQL 逻辑复制开始时还未结束的事务是否会丢失?》
《PostgreSQL 10.0 preview 变化 - 逻辑复制pg_hba.conf变化,不再使用replication条目》
《PostgreSQL 10.0 preview 功能增强 - 逻辑复制支持并行COPY初始化数据》
《PostgreSQL 逻辑订阅 - DDL 订阅 实现方法》
《使用PostgreSQL逻辑订阅实现multi-master》
《PostgreSQL 10.0 preview 功能增强 - 逻辑订阅端worker数控制参数》
《PostgreSQL 逻辑订阅 - 给业务架构带来了什么希望?》
《PostgreSQL 10.0 preview 功能增强 - 物理备库支持逻辑订阅,订阅支持物理主备HA漂移》
《PostgreSQL 10.0 preview 逻辑订阅 - 原理与最佳实践》
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.