Migration Tutorial
An auxiliary playbook, pgsql-migration.yml, provides a battery-included migration method based on logical replication.
By filling in the information about the source and host clusters, the playbook will automatically create the scripts needed for the migration and simply execute them in sequence during the database migration.
Prepare
SRC and DST Clusters
Suppose you want to migrate the pg-meta cluster in the sandbox (containing the Pigsty meta DB with the pgbench test tables) to the pg-test cluster.
First, create a new empty target cluster pg-test, then edit the variables list in pgsql-migration.yml and fill in the relevant information (connection information for the host cluster’s primary).
Execute pgsql-migration.yml, which by default creates the ~/migration/pg-meta.meta dir on the meta node, containing the resources and scripts used for the migration.
Manual Template
Announcement
- Operation Notice
- Business Party Notification
Preparations
- Prepare source and host clusters
- Repair Source HBA
- Create Source Replication User
- External Resource Request
- Create Cluster Profile
- Configure business users
- Configure business database
- Configure business whitelist
- Create business cluster
- Fix Replication Identity
- Identify migration target
- Generate schema synchronization command
- Generate serial number synchronization command
- Generate create publish command
- Generate create subscription command
- Generate progress check command
- Generate check command
Stock Migration
- Synchronize database schema
- Create publish at the source
- Create a subscription to host
- Wait for logical replication sync
Switch moment
- Prepare
- Stop source write traffic
- Synchronize sequence numbers with other objects
- Verify data consistency
- Flow Switching
- Aftercare