A utility for automatically configuring PostgreSQL databases with Exoquic datastreaming platform.
This tool automates the process of setting up PostgreSQL for logical replication, which is required for Exoquic. It handles all the necessary configuration changes, user creation, and replication setup to enable real-time data streaming from your PostgreSQL database.
The Exoquic PostgreSQL Configurator performs the following tasks:
- WAL Settings:
- Sets
wal_leveltological(required for logical replication) - Increases
max_replication_slotsto at least 5 - Increases
max_wal_sendersto at least 5 - Reloads PostgreSQL configuration after changes
- Sets
-
Replication User:
- Creates a dedicated user with replication privileges
- Grants necessary permissions for CDC operations
-
Publication:
- Creates a PostgreSQL publication that defines which tables to replicate
- Can be configured for all tables or specific tables only
-
Replication Slot:
- Creates a logical replication slot that Exoquic uses to consume changes
- Uses the pgoutput plugin for logical decoding
-
Exoquic Schema:
- Creates an
exoquicschema with helper objects - Includes a status view for monitoring replication
- Creates an
- REPLICA IDENTITY FULL:
- Identifies tables without primary keys
- Sets
REPLICA IDENTITY FULLfor these tables to ensure all column values are included in change events - Provides recommendations for adding primary keys for better performance
-
Connection Information:
- Generates connection details needed for Exoquic configuration
- Includes host, port, database, username, replication slot, and publication
-
Cloud Registration (optional):
- If an API key is provided, registers the database with Exoquic cloud
- Sends necessary connection details securely to the Exoquic API
After this tool completes its configuration:
-
Change Tracking: PostgreSQL's logical replication system tracks all data changes (inserts, updates, deletes) in the Write-Ahead Log (WAL).
-
Logical Decoding: The changes are decoded from the binary WAL format into a logical representation using the pgoutput plugin.
-
Replication Slot: The created replication slot maintains a pointer to the last consumed WAL position, ensuring no changes are missed, even if Exoquic is temporarily disconnected.
-
Publication: The publication defines which tables' changes should be captured and made available for consumption.
-
Consumption: Exoquic connects to PostgreSQL using the replication user credentials and reads changes from the replication slot, processing them according to your configuration.
-
Data Delivery: Exoquic then delivers these events to your authorized Kafka, MQTT, AMQP, STOMP, Websocket and HTTP clients.
PGHOST: PostgreSQL host addressPGUSER: PostgreSQL admin username (requires superuser privileges)PGPASSWORD: PostgreSQL admin passwordPGDATABASE: PostgreSQL database nameEXOQUIC_REPLICATION_PASSWORD: Password for the replication user
PGPORT: PostgreSQL port (default: 5432)EXOQUIC_REPLICATION_USER: Username for the replication user (default: exoquic_replication)EXOQUIC_PUBLICATION_NAME: Name of the publication (default: exoquic_publication)EXOQUIC_SLOT_NAME: Name of the replication slot (default: exoquic_replication_slot)EXOQUIC_API_KEY: API key for Exoquic cloud registration (optional)EXOQUIC_CLOUD_URL: URL for Exoquic cloud API (default: https://api.exoquic.com)TABLES_TO_CAPTURE: Comma-separated list of tables to include in the publication (default: all tables)
# Set required environment variables
export PGHOST=localhost
export PGUSER=postgres
export PGPASSWORD=your_password
export PGDATABASE=your_database
export EXOQUIC_REPLICATION_PASSWORD=replication_password
# Optional: Specify tables to capture
export TABLES_TO_CAPTURE="table1,table2,table3"
# Run the configurator
go run main.go- Deploy exoquic-postgres-configurer template
- View runtime logs to make sure WAL settings have been modified.
- Restart the postgres server for the WAL settings to apply.
- You're good to go!
- Superuser Privileges: The PostgreSQL user specified in
PGUSERmust have superuser privileges to modify WAL settings. - Server Restart: Some WAL configuration changes require a PostgreSQL server restart to take effect.
- Tables Without Primary Keys: For optimal performance, it's recommended to add primary keys to all tables. Tables without primary keys will work but require more resources.
- Security: The replication user is created with minimal necessary permissions for CDC operations.
if you have any questions, create an issue!