Preparing Postgres source databases
Configuring Postgres for EDB Data Migration Service (EDB DMS) requires administrative privileges. Create a change data capture (CDC) migration role with limited privileges for data migration.
Execute SQL statements with psql or a similar client.
To connect to the source database using psql
:
Where:
<PG_DB_NAME>
is the name of the Postgres database source to connect to.<PG_HOST>
is the Postgres database host.<PG_PORT>
is the Postgres database port.<PG_USERNAME>
is an administrative user who can create and grant roles, alter ownership of tables to migrate, and create a replication slot.
This command prompts you for the password associated with <PG_USERNAME>
.
Postgres database configuration
To prepare the source Postgres database configuration:
- Set the Postgres configuration.
- Create new roles and grant acccess for CDC migration.
- Grant usage of the source schemas to the CDC migration role.
- Grant
SELECT
on source tables to the CDC migration role. - Grant
CREATE
privileges on the source database to the CDC migration role.
Set the Postgres configuration
Ensure the following configuration entries for Postgres are set as follows:
Ensure
wal_level
is configured aslogical
.The CDC migration process leverages Postgres logical decoding. Setting
wal_level
tological
enables logical decoding of the Postgres write-ahead log (WAL).Ensure
max_wal_senders
is configured appropriately.If EDB Data Migration Service migration is the first streaming client for your database, set
max_wal_senders
to at least1
. Other streaming clients might be present. Consult your DBA for the appropriate value for streaming client connectivity.Ensure
max_replication_slots
is configured appropriately.max_replication_slots
must be at least1
for the CDC migration process. This value can be higher if your organization uses Postgres replication.See the Postgres replication documentation for more information.
Ensure
max_wal_size
is configured for adequate WAL LSN lifetime.Set the
max_wal_size
value large enough that production traffic is generating mostly timed checkpoints and not requested checkpoints based on WAL size.The streaming migration process also requires changes to be available in the WAL until they can be streamed to durable message storage in the cloud infrastructure of EDB DMS. Setting
max_wal_size
too small can affect performance. It can also interfere with the migration process by allowing Postgres LSNs to be dropped from the WAL before they can be streamed.For more information, see this EDB blog post on tuning
max_wal_size
and the Postgres WAL documentation.
Config validation script
The EDB DMS Reader installation (packaged as cdcreader
) comes with a helper script that validates the Postgres configuration and helps you identify any issues. After you configure the database, we recommend running the script and ensuring all checks passed.
Run the script without arguments to print the usage: