首页 > 解决方案 > 使用 AWS DMS 进行 Postgres 到 Postgres 数据迁移时,如何修复“列“xlog_position”不存在”错误

问题描述

我正在尝试使用 AWS DMS 迁移和同步 PostgreSQL 数据库,但出现以下错误。

Last Error Task error notification received from subtask 0, thread 0 [reptask/replicationtask.c:2673] [1020487] 
RetCode: "SQL_ERROR SqlState: 42703 NativeError: 1 
Message: ERROR: column "xlog_position" does not exist; No query has been executed with that handle; RetCode: SQL_ERROR SqlState: 42P01 NativeError: 1 
Message: ERROR: relation "pglogical.replication_set" does not exist; No query has been executed with that handle; RetCode: SQL_ERROR SqlState: 42703 NativeError: 1 Message: ERROR: column "xlog_position" does not exist; No query has been executed with that handle; 
Could not find any supported plugins available on source; Could not resolve default plugin; Could not assign a postgres plugin to use for replication; Failure in setting Postgres CDC agent control structure; Error executing command; Stream component failed at subtask 0, component st_0_JX7ONUUGB4A2AR2VQ4FMEZ7PFU ; Stream component 'st_0_JX7ONUUGB4A2AR2VQ4FMEZ7PFU' terminated [reptask/replicationtask.c:2680] [1020487] Stop Reason FATAL_ERROR Error Level FATAL

我使用两个 PostgreSQL 实例作为源和目标。我已经测试并验证了复制实例可以访问两个数据库实例。目标实例用户对数据库具有完全访问权限。我是否需要安装任何插件或进行其他配置才能使此迁移设置正常工作?

标签: amazon-web-servicesaws-dms

解决方案


为 Amazon RDS for PostgreSQL 数据库实例启用逻辑解码

  1. 用户帐户需要rds_superuser角色才能启用逻辑复制。用户帐户还需要该rds_replication角色授予管理逻辑槽和使用逻辑槽流式传输数据的权限。

  2. 将 rds.logical_replication 静态参数设置为 1。作为应用此参数的一部分,我们还设置了参数wal_levelmax_wal_sendersmax_replication_slotsmax_connections。这些参数更改会增加 WAL 生成,因此您应该只在rds.logical_replication使用逻辑插槽时设置该参数。

  3. 重启数据库实例,使静态rds.logical_replication 参数生效。

  4. 按照下一节中的说明创建一个逻辑复制槽。此过程需要您指定解码插件。目前我们支持 PostgreSQL 附带的 test_decoding 输出插件。

最后一项可以使用以下命令完成:

SELECT * FROM pg_create_logical_replication_slot('test_slot', 'test_decoding');

参考:https ://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.FeatureSupport.LogicalReplication


推荐阅读