AlloyDB Postgres source setup guide
Supported versions
To propagate data from your AlloyDB instance to ClickHouse Cloud using ClickPipes, your instance must be configured for logical replication. This is supported from AlloyDB Version 14.
Enable logical replication
To check if logical replication is enabled in your AlloyDB instance, run the following query against your primary instance:
If the result is logical, logical replication is already enabled and you can skip to the next step. If the result is replica, you must set the alloydb.enable_pglogical and alloydb.logical_decoding flags to on in the primary instance.
As noted in the AlloyDB flags documentation, modifying the flags that enable logical replication requires a restart of the primary instance.
To enable these flags:
-
In the Google Cloud Console, navigate to the AlloyDB Clusters page. From the Actions menu for your primary instance, click Edit.
-
Scroll down to Advanced configuration options and expand the section. Under Flags, click Add a database flag.
- Add the
allowdb.enable_pglogicalflag and set its value toon - Add the
alloydb.logical_decodingflag and set its value toon
- Add the
-
Click Update instance to save the configuration changes. It's important to note that this action triggers a restart of the primary instance.
-
Once the status of the instance changes from
UpdatingtoReady, run the following query against your primary instance to verify that logical replication is enabled:The result should be
logical.
Create a ClickPipes user and manage replication permissions
Connect to your AlloyDB instance as an admin user and execute the following commands:
-
Create a dedicated user for ClickPipes:
-
Grant the dedicated user permissions on the schema(s) you want to replicate.
The example above shows permissions for the
publicschema. Repeat the sequence of commands for each schema you want to replicate using ClickPipes. -
Grant the dedicated user permissions to manage replication:
-
Create a publication with the tables you want to replicate. We strongly recommend only including the tables you need in the publication to avoid performance overhead.
NoteAll tables included in the publication must either have a primary key defined or have its replica identity configured to
FULL. See the Postgres FAQs for guidance on scoping.-
To create a publication for specific tables:
-
To create a publication for all tables in a specific schema:
The
clickpipespublication will contain the set of change events generated from the specified tables, and will later be used to ingest the replication stream. -
Configure network security
ClickPipes does not support Private Service Connect (PSC) connections. If you do not allow public access to your AlloyDB instance, you can use an SSH tunnel to connect securely. PSC will be supported in the future.
Next, you must allow connections to your AlloyDB instance from ClickPipes.
- Allow ClickPipes IPs
- Use an SSH tunnel
-
In the Google Cloud Console, navigate to the AlloyDB Clusters page. Select your primary instance to open the Overview page.
-
Scroll down to Instances in your cluster and click Edit primary.
-
Check the Enable Public IP checkbox to allow connections to the instance over the public internet. Under Authorized external networks, enter the list of ClickPipes static IP addresses for the region your service is deployed in.
NoteAlloyDB expects addresses to be specified in CIDR notation. You can adapt the provided list of ClickPipes static IP addresses to follow this notation by appending
/32to each address. -
Under Network Security, select Require SSL Encryption (default) (if not already selected).
-
Click Update instance to save the network security configuration changes.
If you do not allow public access to your AlloyDB instance, you must first set up an SSH bastion host to securely tunnel your connection. To set up an SSH bastion host on Google Cloud Platform:
-
Create and start a Google Compute Engine (GCE) instance following the official documentation.
- Ensure the GCE instance is in the same Virtual Private Network (VPC) as your AlloyDB instance.
- Ensure the GCE instance has a static public IP address. You’ll use this IP address when connecting ClickPipes to your SSH bastion host.
-
Update the firewall rules of the SSH bastion host to allow traffic from the list of ClickPipes static IP addresses for the region your service is deployed in.
-
Update the firewall rules of AlloyDB to allow traffic from the SSH bastion host.
What's next?
You can now create your ClickPipe and start ingesting data from your Postgres instance into ClickHouse Cloud. Make sure to note down the connection details you used while setting up your Postgres instance as you will need them during the ClickPipe creation process.