Replication
Markus Hennecke редагує цю сторінку 4 роки тому

PostgreSQL logical replication of data tables

Config file changes

Required changes to postgresql.conf config file

listen_addresses = 'localhost, $PRIVATE_IP_ADDRESS'

wal_level = 'logical'

Required changes to pg_hba.conf config file

Add the hosts IP address that should be receiving the replication as an allowed log in like this:

host weatherdata weatherdata_replicant $PRIVATE_IP_ADDRESS/32 md5

Database setup on the master

CREATE USER weatherdata_replicant WITH REPLICATION;
GRANT SELECT ON data TO weatherdata_replicant;
CREATE PUBLICATION weatherdata_publication1 FOR TABLE data;

Database setup on the replication host

Create the database and the data table. In the database create a new subscription to the data table of the master:

CREATE SUBSCRIPTION weatherdata_subscription1 CONNECTION 'host=$PRIVATE_IP_ADDRESS port=5432 dbname=weatherdata user=weatherdata_replicant password=$PASSWORD' PUBLICATION weatherdata_publication1;