Skip to main content
Skip to main content
Edit this page

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:

SHOW  wal_level;

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.

Note

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:

  1. In the Google Cloud Console, navigate to the AlloyDB Clusters page. From the Actions menu for your primary instance, click Edit.

  2. Scroll down to Advanced configuration options and expand the section. Under Flags, click Add a database flag.

  3. Click Update instance to save the configuration changes. It's important to note that this action triggers a restart of the primary instance.

  4. Once the status of the instance changes from Updating to Ready, run the following query against your primary instance to verify that logical replication is enabled:

    SHOW  wal_level;
    

    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:

  1. Create a dedicated user for ClickPipes:

    CREATE USER clickpipes_user PASSWORD 'some-password';
    
  2. Grant the dedicated user permissions on the schema(s) you want to replicate.

    GRANT USAGE ON SCHEMA "public" TO clickpipes_user;
    GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO clickpipes_user;
    ALTER DEFAULT PRIVILEGES IN SCHEMA "public" GRANT SELECT ON TABLES TO clickpipes_user;
    

    The example above shows permissions for the public schema. Repeat the sequence of commands for each schema you want to replicate using ClickPipes.

  3. Grant the dedicated user permissions to manage replication:

    ALTER ROLE clickpipes_user REPLICATION;
    
  4. 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.

    Note

    All 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:

      CREATE PUBLICATION clickpipes FOR TABLE table_to_replicate, table_to_replicate2;
      
    • To create a publication for all tables in a specific schema:

      CREATE PUBLICATION clickpipes FOR TABLES IN SCHEMA "public";
      

    The clickpipes publication 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

Note

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.

  1. In the Google Cloud Console, navigate to the AlloyDB Clusters page. Select your primary instance to open the Overview page.

  2. Scroll down to Instances in your cluster and click Edit primary.

  3. 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.

    Note

    AlloyDB 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 /32 to each address.

  4. Under Network Security, select Require SSL Encryption (default) (if not already selected).

  5. Click Update instance to save the network security configuration changes.

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.