Configuring PostgreSQL to use PostgreSQL Reader
Striim reads change data from PostgreSQL.
Note
PostgreSQL Reader requires logical replication. For general information about PostgreSQL logical replication, see https://www.postgresql.org/docs/current/logical-replication.html and select your PostgreSQL version.
Before Striim applications can use the PostgreSQL Reader adapter, a PostgreSQL administrator with the necessary privileges must set up your database as described for your platform.
PostgreSQL setup in Amazon Aurora with PostgreSQL compatibility
You must set up replication at the cluster level. This will require a reboot, so it should probably be performed during a maintenance window.
Amazon Aurora supports logical replication for PostgreSQL compatibility options 10.6 and later. Automated backups must be enabled. To set up logical replication, your AWS user account must have the rds_superuser role.
For additional information, see Using PostgreSQL logical replication with Aurora, Replication with Amazon Aurora PostgreSQL, and Using logical replication to replicate managed Amazon RDS for PostgreSQL and Amazon Aurora to self-managed PostgreSQL.
Go to your RDS dashboard, select Parameter groups > Create parameter group.
For the Parameter group family, select the aurora-postgresql item that matches your PostgreSQL compatibility option (for example, for PostgreSQL 11, select aurora-postgresql11).
For Type, select DB Cluster Parameter Group.
For Group Name and Description, enter
aurora-logical-decoding
, then click Create.Click aurora-logical-decoding.
Enter
logical_
in the Parameters field to filter the list, click Modify, set rds.logical_replication to 1, and click Continue > Apply changes.In the left column, click Databases, then click the name of your Aurora cluster, click Modify, scroll down to Database options (you may have to expand the Additional configuration section), change DB cluster parameter group to aurora-logical-decoding, then scroll down to the bottom and click Continue.
Select Apply immediately > Modify DB instance. Wait for the cluster's status to change from Modifying to Available, then stop it, wait for the status to change from Stopping to Stopped, then start it.
In PSQL, enter the following command to create the replication slot:
SELECT pg_create_logical_replication_slot('striim_slot', 'wal2json');
Create a role with the REPLICATION attribute for use by PostgreSQLReader and give it select permission on the schema(s) containing the tables to be read. Replace ****** with a strong password and (if necessary)
public
with the name of your schema.CREATE ROLE striim WITH LOGIN PASSWORD '******'; GRANT rds_replication TO striim; GRANT SELECT ON ALL TABLES IN SCHEMA public TO striim;
PostgreSQL setup in Amazon RDS for PostgreSQL
You must set up replication in the master instance. This will require a reboot, so it should probably be performed during a maintenance window.
Amazon RDS supports logical replication only for PostgreSQL version 9.4.9, higher versions of 9.4, and versions 9.5.4 and higher. Thus PostgreSQLReader can not be used with PostgreSQL 9.4 - 9.4.8 or 9.5 - 9.5.3 on Amazon RDS.
For additional information, see Best practices for Amazon RDS PostgreSQL replication and Using logical replication to replicate managed Amazon RDS for PostgreSQL and Amazon Aurora to self-managed PostgreSQL.
Go to your RDS dashboard, select Parameter groups > Create parameter group, enter
posstgres-logical-decoding
as the Group name and Description, then click Create.Click postgres-logical-decoding.
Enter
logical_
in the Parameters field to filter the list, click Modify, set rds.logical_replication to 1, and click Continue > Apply changes.In the left column, click Databases, then click the name of your database, click Modify, scroll down to Database options (you may have to expand the Additional configuration section), change DB parameter group to postgres-logical-decoding, then scroll down to the bottom and click Continue.
Select Apply immediately > Modify DB instance. Wait for the database's status to change from Modifying to Available, then reboot it and wait for the status to change from Rebooting to Available.
In PSQL, enter the following command to create the replication slot:
SELECT pg_create_logical_replication_slot('striim_slot', 'wal2json');
Create a role with the REPLICATION attribute for use by PostgreSQLReader and give it select permission on the schema(s) containing the tables to be read. Replace ****** with a strong password and (if necessary)
public
with the name of your schema.CREATE ROLE striim WITH LOGIN PASSWORD '******'; GRANT rds_replication TO striim; GRANT SELECT ON ALL TABLES IN SCHEMA public TO striim;
PostgreSQL setup in Azure
Azure Database for PostgreSQL - Hyperscale is not supported because it does not support logical replication.
Set up logical decoding using wal2json:
for Azure Database for PostgreSQL, see Logical decoding
for Azure Database for PostgreSQL Flexible Server, see Logical replication and logical decoding in Azure Database for PostgreSQL - Flexible Server
Specify PostgreSQL Reader's properties as follows:
Postgres Config: if using wal2json version 2, specify that as described in PostgreSQL Reader properties
Replication slot name: see Logical decoding
Username: see Quickstart: Create an Azure Database for PostgreSQL server by using the Azure portal
Password: the login password for that user
PostgreSQL setup in Google Cloud SQL for PostgreSQL or Google AlloyDB for PostgreSQL
Set up logical replication as described in Setting up logical replication and decoding.
Specify PostgreSQL Reader's properties as follows:
Replication slot name: the name of the slot created in the "Create replication slot" section of Receiving decoded WAL changes for change data capture (CDC)
Username: the name of the user created in Create a replication use
Password: the login password for that user
PostgreSQL setup in Linux or Windows
This will require a reboot, so it should probably be performed during a maintenance window.
Install the wal2json plugin for the operating system of your PostgreSQL host as described in https://github.com/eulerto/wal2json.
Edit
postgressql.conf
, set the following options, and save the file. The values for max_replication_slots and max_wal_senders may be higher but there must be one of each available for each instance of PostgreSQL Reader. max_wal_senders cannot exceed the value of max_connections.wal_level = logical max_replication_slots = 1 max_wal_senders = 1
Edit
pg_hba.conf
and add the following records, replacing<IP address>
with the Striim server's IP address. If you have a multi-node cluster, add a record for each server that will run PostgreSQLReader. Then save the file and restart PostgreSQL.local replication striim <IP address>/0 trust local replication striim trust
Restart PostgreSQL.
Enter the following command to create the replication slot (the location of the command may vary but typically is
/usr/local/bin
in Linux orC:\Program Files\PostgreSQL\<version>\bin\
in Windows.pg_recvlogical -d mydb --slot striim_slot --create-slot -P wal2json
If you plan to use multiple instances of PostgreSQL Reader, create a separate slot for each.
Create a role with the REPLICATION attribute for use by Striim and give it select permission on the schema(s) containing the tables to be read. Replace ****** with a strong password and
myschema
with the name of your schema.CREATE ROLE striim WITH LOGIN PASSWORD '******' REPLICATION; GRANT SELECT ON ALL TABLES IN SCHEMA public TO striim;
PostgreSQL setup for schema evolution
Using Schema evolution with PostgreSQL Reader requires a tracking table in the source database. To create this table, run pg_ddl_setup.sql
, which you can find in Striim/conf/DDLCaptureScripts
or download from https://github.com/striim/doc-downloads.