Step 2: Configure Your Source Database - Database Migration Guide

Step 2: Configure Your Source Database

In this step, you create a new database user on your source PostgreSQL database and configure the data replication.

Use the following script to create a database user with the required permissions in your PostgreSQL source database.

CREATE USER your_user WITH LOGIN PASSWORD 'your_password'; ALTER USER your_user WITH SUPERUSER; GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO your_user;

In the preceding example, replace your_user with the name of your user. Next, replace your_password with a secure password. Finally, replace schema_name with the name of your database schema. Run the GRANT query for each schema that you migrate to AWS.

To replicate ongoing changes in your source database after the data migration, configure the logical replication. To turn on logical replication, set the following parameters and values in the postgresql.conf configuration file.

  • Set wal_level to logical.

  • Set max_replication_slots to a value greater than 1. Set the max_replication_slots value according to the number of tasks that you want to run. For example, to run five tasks you set a minimum of five slots. Slots open automatically as soon as a migration starts and remain open even when the migration is no longer running. Make sure to manually delete open slots.

  • Set max_wal_senders to a value greater than 1. The max_wal_senders parameter sets the number of concurrent tasks that can run.

  • The wal_sender_timeout parameter ends replication connections that are inactive longer than the specified number of milliseconds. The default is 60000 milliseconds (60 seconds). Setting the value to 0 (zero) disables the timeout mechanism.

After you edit the postgresql.conf configuration file, restart your PostgreSQL database server to apply new values of static parameters.