Replicating PostgreSQL data

You can replicate data from PostgreSQL to other databases with Data Replication.

To set up replication for PostgreSQL, first configure your PostgreSQL database and user, and then add a connection to it in a project.

Restrictions

  • You can use this connection only as a source for Data Replication. You cannot use this connection as a target connection.
  • You can replicate only some PostgreSQL data types. See Supported PostgreSQL data types.

Supported versions

PostgreSQL database versions 10, 11 and 12

Configuring the PostgreSQL database for replication

To set up PostgreSQL:

  1. Open the postgresql.conf file in text editor. The location of the file can vary depending on your operating system and PostgreSQL installation, but it is typically located in the data directory of your PostgreSQL installation.

  2. Search for the wal_level parameter in the file.

  3. Change the value of the wal_level parameter from its current setting to logical. If the wal_level parameter does not exist in the file, you can add it to the end of the file as a new line.

  4. Set the max_replication_slots and max_wal_senders parameters to the number of concurrent Data Replication assets you want to run.

  5. Save the changes to the postgresql.conf file and exit the text editor.

  6. Restart the PostgreSQL server for the changes to take effect. On most systems, you can do this by running the following command. This command will vary depending on the operating system and how PostgreSQL is installed.

    sudo systemctl restart postgresql
    
  7. Apply the changes to the database.

  8. Grant roles to the database username. Ask your database administrator to grant the roles superuser and replication to the username you use in the connection for Data Replication by running:

    ALTER USER username WITH superuser;
    ALTER USER username WITH replication;
    

Connecting to PostgreSQL in a project

To connect to PostgreSQL in a project in Cloud Pak for Data, see PostgreSQL connection.

Next step

Starting Data Replication

Parent topic: Supported Data Replication connections