By Andre Kramadibrata, Solution Architect Alibaba Cloud Indonesia
When migrating a self-managed PostgreSQL database to Alibaba Cloud ApsaraDB RDS using the Data Transmission Service (DTS), incremental data migration relies heavily on logical decoding. To facilitate this, Alibaba Cloud requires the installation of their proprietary ali_decoding plugin.
However, a common architectural friction point arises for system administrators running PostgreSQL via Ubuntu’s standard apt package manager.
The official DTS documentation assumes you are working within a source-compiled PostgreSQL environment. If you compile the plugin from source and run make install, the binaries default to the /usr/local/pgsql/ prefix.
Meanwhile, your apt-installed PostgreSQL service is looking for extensions in the Linux Standard Base (LSB) paths (/usr/lib/postgresql/...).
This guide details the "Compile and Map" strategy: building the extension artifacts in a sterile environment and manually mapping them into your production package-managed server.
To avoid cluttering your production database server with build tools, it is best practice to compile the extension on a clone or a temporary sandbox instance.
During the make install process, you will notice the system outputs the installation paths. By default, it places the artifacts here:
/usr/local/pgsql/lib/ali_decoding.so
/usr/local/pgsql/share/extension/ali_decoding.control
/usr/local/pgsql/share/extension/ali_decoding--0.0.1.sql
Because your production instance was installed via apt, it will completely ignore the /usr/local/pgsql/ directory. We must manually map the generated artifacts to the exact directories where the apt installation expects to find them.
Here is the necessary mapping matrix for PostgreSQL 9.6:
| Artifact Type | Source Location (Compiled Default) | Target Location (Ubuntu apt Package) |
| Shared Library (.so) | /usr/local/pgsql/lib/ |
/usr/lib/postgresql/9.6/lib/ |
| Control File (.control) | /usr/local/pgsql/share/extension/ |
/usr/share/postgresql/9.6/extension/ |
| SQL Script (.sql) | /usr/local/pgsql/share/extension/ |
/usr/share/postgresql/9.6/extension/ |
To inject the compiled extension into your production server, transfer the files from your sandbox and execute the following commands to place them in the correct LSB directories.
1. Copy the artifacts:
#Move the compiled binary
sudo cp /path/to/sandbox/ali_decoding.so /usr/lib/postgresql/9.6/lib/
#Move the extension metadata
sudo cp /path/to/sandbox/ali_decoding.control /usr/share/postgresql/9.6/extension/
sudo cp /path/to/sandbox/ali_decoding--*.sql /usr/share/postgresql/9.6/extension/
2. Enforce correct ownership and permissions:
The postgres system user must be able to read and execute these files.
sudo chmod 755 /usr/lib/postgresql/9.6/lib/ali_decoding.so
sudo chmod 644 /usr/share/postgresql/9.6/extension/ali_decoding*
With the files mapped correctly, PostgreSQL will now recognize the extension as if it were installed natively via a package manager.
1. Enable Logical Replication:
Edit your /etc/postgresql/9.6/main/postgresql.conf to support DTS logical decoding requirements:
wal_level = logical
max_wal_senders = 10 # Adjust based on concurrent connections
max_replication_slots = 10 # Adjust based on replication slot needs
1.
2. Restart the Service:
Apply the configuration changes.
sudo systemctl restart postgresql
By understanding the routing differences between source-compiled defaults and OS package managers, you can manually bridge the gap for proprietary plugins. Your Alibaba Cloud DTS task should now successfully pass its pre-checks and begin synchronizing your incremental data!
Boost Your Coding Workflow with Qwen Code: A Practical Guide
126 posts | 22 followers
FollowAlibaba Cloud Indonesia - August 12, 2024
digoal - September 17, 2019
Alibaba Clouder - March 22, 2019
Alibaba Cloud MaxCompute - September 18, 2018
Alibaba Clouder - December 3, 2019
digoal - July 19, 2023
126 posts | 22 followers
Follow
PolarDB for PostgreSQL
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn More
Time Series Database (TSDB)
TSDB is a stable, reliable, and cost-effective online high-performance time series database service.
Learn More
Big Data Consulting for Data Technology Solution
Alibaba Cloud provides big data consulting services to help enterprises leverage advanced data technology.
Learn More
Cloud Migration Solution
Secure and easy solutions for moving you workloads to the cloud
Learn MoreMore Posts by Alibaba Cloud Indonesia