PostgreSQL Replication Setup

Complete guide for setting up real-time logical replication between PostgreSQL/EDB instances

Introduction

Helyx is a lightweight, high-performance replication solution designed for real-time heterogeneous database replication. It provides a simple CLI-driven experience and abstracts the complexity of setting up connectors, schema registry, and replication pipelines.

Key highlights of Helyx:

  • Heterogeneous Replication: Supports replication across multiple database systems (e.g., PostgreSQL ↔ PostgreSQL, Oracle ↔ Oracle, Oracle β†’ PostgreSQL, Oracle β†’ MySQL, Oracle β†’ MongoDB, Oracle β†’ Snowflake).
  • High Throughput: Capable of handling hundreds of thousands of transactions per second across distributed data centers.
  • Schema Evolution Handling: Automatically adapts to schema changes like column additions and keeps source and target databases in sync.
  • Zero-Downtime Replication: Supports ad-hoc snapshots and live streaming without interrupting production workloads.
  • Monitoring & Control: Built-in CLI commands allow users to check replication lag, list connectors, view tasks, and monitor end-to-end replication health.
  • Deployment Friendly: Delivered as self-contained executables and RPM packages, making installation and upgrades straightforward.
  • Version-Aware Replication: Helyx supports replication between different versions of the same technology stack (e.g., PostgreSQL 11 β†’ PostgreSQL 15 or EDB 12 β†’ EDB 14 or Oracle11g β†’ Oracle19c). This ensures smooth migrations and upgrades without downtime.

With Helyx, enterprises can achieve enterprise-grade replication with lower operational overhead, faster setup, and proven reliability compared to traditional tools.

Helyx Installation Guide

1. Overview

Helyx is distributed as an RPM package to simplify installation and management. By default, Helyx is installed in the directory /var/lib/helyx.

This section describes the steps to install Helyx from a standard YUM/DNF repository as well as from a local repository if you download the RPM manually.

2. Prerequisites

  • Operating System: Linux (RHEL, CentOS, Rocky Linux, Oracle Linux, Fedora, etc.).
  • Privileges: Root or sudo access.
  • Package Manager: yum or dnf depending on your OS version.
  • Network Access (for online installation): Access to the configured YUM repository

Installing Helyx from a Local Repository

Create Local Repository Directory:

mkdir -p /opt/localrepo/helyx

cp helyx-1.1.0.rpm /opt/localrepo/helyx/

Create Repository Metadata:

cd /opt/localrepo/helyx

createrepo .

Add Local Repository Entry (create /etc/yum.repos.d/helyx-local.repo):

[helyx-local]
name=Helyx Local Repository
baseurl=file:///opt/localrepo/helyx
enabled=1
gpgcheck=0

Install from Local Repository:

sudo yum install helyx -y

Post installation verifies and ensures binaries are installed under /var/lib/helyx location.

Target: Set up real-time replication between PostgreSQL/EDB source and destination with different versions as well as same version.

Prerequisites

Java 11 or above
Replication Binaries
PostgreSQL or EDB installed at source and destination
JDBC connectors come pre-build with Binaries
Config tools: tabletorepl, serverconfig and configservice
wal_level = logical for both Source and Destination postgresql/EDB Databases

Directory Structure

/var/lib/helyx/replconfig
β”œβ”€β”€ publication.config
β”œβ”€β”€ subscription.config
β”œβ”€β”€ tablelist.config
β”œβ”€β”€ tabletorepl
β”œβ”€β”€ serverconfig
└── configservice

Step 1: Setup Replication & Related Services

Ensure these services are configured and started:

1. Sync-manager service:

./configservice -start sync-manager

2. Broker Service:

Edit /var/lib/helyx/ server.properties and set:

listeners = PLAINTEXT://your.host.name:9092

your.host.name will be the IP address of the server where Helyx is running.

Now start broker service:

./configservice -start broker

3. Registry Service:

Edit /var/lib/helyx/plugins/confluent-7.5.0/etc/schema-registry/schema-registry.properties and ensure:

kafkastore.bootstrap.servers=PLAINTEXT://<your.host.name>:9092

listeners=http://0.0.0.0:8081

your.host.name will be the IP address of the server where Helyx is running.

./configservice -start schemaregistry

4. Connect Service:

Edit /var/lib/helyx/config/connect-distributed.properties and set:

bootstrap.servers=<your.server.ip>:9092

key.converter.schema.registry.url=http://<your.server.ip>:8081

value.converter.schema.registry.url=http://<your.server.ip>:8081
./connectservice -start connect

Step 2: Configure Source Database

Creating Helyx User in Source Database

In order for Helyx to perform replication, a dedicated database user with appropriate privileges must be created. This section describes the SQL commands required to create the helyx role, schema, and associated privileges on the source database.

CREATE ROLE helyx WITH LOGIN REPLICATION PASSWORD 'password';
CREATE SCHEMA IF NOT EXISTS helyx;
GRANT CONNECT ON DATABASE edb TO helyx;
GRANT CREATE ON DATABASE edb TO helyx;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA helyx TO helyx;
ALTER DEFAULT PRIVILEGES IN SCHEMA helyx
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO helyx;

Change publication.config file

Edit /var/lib/helyx/replconfig/publication.config with the following keys:

"name": "",                       // Unique identifier
"tasks.max": "1",                // Parallelism level
"database.type": "edb",          // edb or postgresql
"database.hostname": "",         // Source DB IP
"database.port": "5444",         // Source DB Port
"database.password": "",         // Source DB β€œhelyx” user password
"database.dbname": "edb",        // Database name
"bootstrap.ip": "",              // Broker Server IP
"include.schema.list": "schema1,schema2,schema3",
"schema.history.internal.kafka.bootstrap.servers": "<serverIP>:9092",
"publication.name": "",          // Logical replication publication name
"snapshot.mode": "initial",
"database.history.kafka.bootstrap.servers": "<serverIP>:9092",
"database.history.kafka.topic": "dbhistory.<Topicname>",
"topic.prefix": "",              // Prefix for Replication topics
"max.batch.size": "2048",
"max.queue.size": 50000,
"poll.interval.ms": "1000",
"producer.batch.size": "32768",
"producer.max.request.size": "10485760"

βœ… Grant Source Permissions Automatically

Enter comma-separated table list at /var/lib/helyx/replconfig/tablelist.config. These are the tables you want to replicate.

Schema1.Table1,
Schema2.Table2,
Schema2.Table3

Then run:

./tabletorepl.jar -s <path_to_publication.config> -tables <path_to_tablelist.config>

For command help: ./tabletorepl.jar -help

Step 3: Configure Destination Database

Creating Helyx User in Destination Database

In order for Helyx to perform replication, a dedicated database user with appropriate privileges must be created. This section describes the SQL commands required to create the helyx role, schema, and associated privileges on the destination database.

CREATE ROLE helyx WITH LOGIN REPLICATION PASSWORD 'password';
ALTER ROLE helyx WITH REPLICATION;
CREATE SCHEMA IF NOT EXISTS helyx AUTHORIZATION helyx;
GRANT CONNECT ON DATABASE edb TO helyx;
GRANT CREATE ON DATABASE edb TO helyx;

Granting Schema Privileges for Helyx User

For schemas listed in include.schema.list of the publication config, grant:

GRANT USAGE ON SCHEMA <schema_name> TO helyx;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA <schema_name> TO helyx;
GRANT CREATE ON SCHEMA <schema_name> TO helyx;
ALTER SCHEMA <schema_name> OWNER TO helyx;
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT ALL ON TABLES TO helyx;
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO helyx;

Note: username will be same at source and destination with the same password.

Change subscription.config file

Edit /var/lib/helyx/replconfig/subscription.config with:

"name": "",   // Unique identifier name
"tasks.max": "1",
"connection.url": "jdbc:postgresql://<Dest_ServerIP>:5444/edb?user=helyx&password=<password>",
"bootstrap.ip": "",  // Kafka IP
"retry.backoff.ms": "1000",
"consumer.max.poll.records": "1000",
"consumer.fetch.max.bytes": "10485760",
"batch.size": "5000",
"max.retries": "10"

Note: User name helyx will NOT be changed

Step 4: Use CLI Tool for Replication Management

Common usages of serverconfig:

ActionCommandCopy
Create publicationserverconfig -createpub -s publication.config -tables tablelist.config
Create subscriptionserverconfig -createsub -s subscription.config -pub publication.config
Add tables to publicationserverconfig -addtabletopub -s publication.config -tables tablelist.config
Trigger ad-hoc snapshotserverconfig -adhocsnapshot -s publication.config -tables table1,table2
Monitor publication statusserverconfig -status -pub -s publication.config
Monitor subscription statusserverconfig -status -sub -s subscription.config
Remove publicationserverconfig -remove -pub -s publication.config
Remove subscriptionserverconfig -remove -sub -s subscription.config
Remove table from replicationserverconfig -removetablefromrepl -s publication.config -tables table1,table2
Encrypt passwordserverconfig -encryptPassword -s publication.config
List connectorsserverconfig -listconnectors -s publication.config
List tasksserverconfig -listtask -s publication.config
Lag statisticsserverconfig -lagstat -s subscription.config
List replicated tablesserverconfig -tablelist -s publication.config

Step 5: Set Up Destination Database (Manual Grants)

On destination DB, execute:

CREATE ROLE helyx WITH LOGIN PASSWORD '<password>';
ALTER ROLE helyx WITH REPLICATION;
GRANT CREATE ON DATABASE <Database Name> TO helyx;
CREATE SCHEMA IF NOT EXISTS helyx AUTHORIZATION helyx;

GRANT USAGE ON SCHEMA <schema_name> TO helyx;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA <schema_name> TO helyx;
GRANT CREATE ON SCHEMA <schema_name> TO helyx;
ALTER SCHEMA <schema_name> OWNER TO helyx;

ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT ALL ON TABLES TO helyx;
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT USAGE ON SEQUENCES TO helyx;
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO helyx;

Note: Please note that username will be same as source and destination database with same password.

Step 6: Use CLI Tool for Starting Replication between servers

Create publication
Creates a logical publication on the source DB using publication.config and tables from tablelist.config.
Create subscription
Sets up the sink connector using subscription.config, and links it to the Kafka topics defined in the publication.
Add tables to publication
Adds new tables so changes in those tables start replicating.
Trigger ad-hoc snapshot
Triggers a one-time snapshot for specified tables; useful for re-syncing.
Monitor publication status
Shows current status of the publication connector (active, paused, failed, etc.).
Monitor subscription status
Displays the running status of the Subscription and its tasks.
Remove publication
Completely stops and removes the publication configuration.
Remove subscription
Stops and deletes the Subscription configuration.
Remove table from replication
Removes selected tables from the ongoing replication setup.
List connectors
Lists all running Kafka connectors on the connect cluster.
List tasks
Displays tasks of a connector, their IDs, and current status (running, failed, paused).
Lag statistics
Shows replication lag metrics to monitor delay in syncing data to the destination.
List replicated tables
Lists all tables currently under replication from the source config.

πŸ“Œ Command Reference

serverconfig -createpub -s publication.config -tables tablelist.config

serverconfig -createsub -s subscription.config -pub publication.config

serverconfig -addtabletopub -s publication.config -tables tablelist.config

serverconfig -adhocsnapshot -s publication.config -tables table1,table2

serverconfig -status -pub -s publication.config

serverconfig -status -sub -s subscription.config

serverconfig -remove -pub -s publication.config

serverconfig -remove -sub -s subscription.config

serverconfig -removetablefromrepl -s publication.config -tables table1,table2

serverconfig -encryptPassword -s publication.config

serverconfig -listconnectors -s publication.config

serverconfig -listtask -s publication.config

serverconfig -lagstat -s subscription.config

serverconfig -tablelist -s publication.config

Start & Monitor

β–Ά Start the Publication

serverconfig -createpub -s publication.config -tables tablelist.config

β–Ά Start the Subscription

serverconfig -createsub -s subscription.config -pub publication.config

β–Ά Monitor Status

serverconfig -status -pub -s publication.config
serverconfig -status -sub -s subscription.config

Final Checklist

sync-manager, broker, Connect, Schema Registry runningβœ…
Source publication.config configuredβœ…
Destination subscription.config configuredβœ…
Grants applied to source and destination DBsβœ…
Topics appearing in Kafkaβœ…
Messages flowing to sinkβœ…

Schema Evolution: Add Column to Replicated Table

If you want to add a new column to a table that is already being replicated, follow these steps carefully:

Purpose

To safely add a new column to an existing replicated table and synchronize the schema with downstream systems.

Steps

1) Stop the Connect Worker service:

systemctl stop connect.service

This ensures that no replication occurs during the schema update.

2) Add the column in the source database:

ALTER TABLE <schema>.<table_name> ADD COLUMN <new_column_name> <datatype>;

3) Start the Connect Worker service:

systemctl start connect.service

The connector will reload the schema change and start applying changes again.

4) Trigger an ad-hoc snapshot for the updated table:

serverconfig -adhocsnapshot -s publication.config -tables <table_name>

This ensures the new column is picked up and replicated to the destination database.

Monitoring & Troubleshooting

Check Helyx Connect logs:

tail -f /var/lib/helyx/logs/connect.log

Validate Schema Registry:

Visit: http://<schema-registry>:8081/subjects

Monitor replication lag:

serverconfig -lagstat -s subscription.config

Need help?

serverconfig -help

Note: Always test on a staging environment before applying to production.

Happy Replication! πŸš€