To migrate data from a self-managed PostgreSQL instance to ApsaraDB RDS for PostgreSQL, create a dedicated database account with replication privileges on the source instance. This account enables the cloud migration feature to stream data from your self-managed instance.
Prerequisites
Before you begin, ensure that you have:
A self-managed PostgreSQL instance deployed on an Elastic Compute Service (ECS) instance or in a data center
Administrative access to the self-managed PostgreSQL instance (a superuser or a role with
CREATEROLEprivilege)An ApsaraDB RDS for PostgreSQL instance as the migration target
Procedure
The migration account requires three permissions: CREATEROLE, REPLICATION, and membership in the pg_monitor role.
If an account with these permissions already exists on the self-managed PostgreSQL instance, skip this procedure and proceed to Update the pg_hba.conf file of a self-managed PostgreSQL instance.
Connect to the self-managed PostgreSQL instance and run the following SQL statement to create the migration account:
CREATE USER migratetest CREATEROLE REPLICATION LOGIN PASSWORD '123456';Note: Replace
123456with a strong, unique password. Do not use the example password in production environments.Parameter Description migratetestAccount name. Replace with your preferred name. CREATEROLEGrants the ability to create and manage roles, required for the migration process. REPLICATIONEnables WAL (Write-Ahead Logging) streaming for data replication. LOGINAllows the account to establish connections. PASSWORDSets the login password for the account. Grant the
pg_monitorrole to the migration account:GRANT pg_monitor TO migratetest;The
pg_monitorrole provides read access to monitoring views and functions used to monitor database server activity, including replication progress.Verify that the account was created with the correct permissions:
SELECT rolname, rolcreaterole, rolreplication FROM pg_roles WHERE rolname = 'migratetest';Expected output:
rolname | rolcreaterole | rolreplication -------------+---------------+---------------- migratetest | t | tTo verify
pg_monitormembership:SELECT pg_has_role('migratetest', 'pg_monitor', 'member');Expected output:
pg_has_role ------------- t
Next steps
Update the pg_hba.conf file of a self-managed PostgreSQL instance