作者
digoal
日期
2022-03-04
标签
PostgreSQL , 逻辑复制 , pglogical
pglogical 基于PG的logical replication protocol, 同时开发了自己的decoder plugin, 支持row_filter, column filter等. 同时打包了大量常用的订阅、发布、DDL的管理函数, 便于操作.
由于采用logical replication protocol, 所以使用pglogical过程中PG原有的logical replication相关系统函数、视图、日志等依旧可以用于排查问题.
https://github.com/2ndQuadrant/pglogical
核心摘要如下
The pglogical 2 extension provides logical streaming replication for PostgreSQL, using a publish/subscribe model. It is based on technology developed as part of the BDR project (http://2ndquadrant.com/BDR).
We use the following terms to describe data streams between nodes, deliberately reused from the earlier Slony technology:
- Nodes - PostgreSQL database instances
- Providers and Subscribers - roles taken by Nodes
- Replication Set - a collection of tables
Use cases supported are:
- Upgrades between major versions (given the above restrictions)
- Full database replication
- Selective replication of sets of tables using replication sets
- Selective replication of table rows at either publisher or subscriber side (row_filter)
- Selective replication of table columns at publisher side
- Data gather/merge from multiple upstream servers
Architectural details:
- pglogical works on a per-database level, not whole server level like physical streaming replication
- One Provider may feed multiple Subscribers without incurring additional disk write overhead
- One Subscriber can merge changes from several origins and detect conflict between changes with automatic and configurable conflict resolution (some, but not all aspects - required for multi-master).
- Cascading replication is implemented in the form of changeset forwarding.
- 支持通过 ddl 复制(必须通过函数执行ddl)
DDL
- Automatic DDL replication is not supported. Managing DDL so that the provider and subscriber database(s) remain compatible is the responsibility of the user.
- pglogical provides the pglogical.replicate_ddl_command function to allow DDL to be run on the provider and subscriber at a consistent point.
详细用法和使用限制, 请参考:
https://github.com/2ndQuadrant/pglogical