Postgresql 中文操作指南

31.11. Quick Setup #

首先在 postgresql.conf 中设置配置选项:

First set the configuration options in postgresql.conf:

wal_level = logical

其余所需设置拥有足以进行基本设置的默认值。

The other required settings have default values that are sufficient for a basic setup.

pg_hba.conf 需要进行调整以允许复制(此处的值取决于你的实际网络配置和你希望用于连接的用户):

pg_hba.conf needs to be adjusted to allow replication (the values here depend on your actual network configuration and user you want to use for connecting):

host     all     repuser     0.0.0.0/0     md5

然后在发布者数据库上:

Then on the publisher database:

CREATE PUBLICATION mypub FOR TABLE users, departments;

在订阅者数据库上:

And on the subscriber database:

CREATE SUBSCRIPTION mysub CONNECTION 'dbname=foo host=bar user=repuser' PUBLICATION mypub;

以上内容将开始复制过程,该过程将同步表 usersdepartments 的初始表格内容,然后开始复制对此类表格的增量更改。

The above will start the replication process, which synchronizes the initial table contents of the tables users and departments and then starts replicating incremental changes to those tables.