我正在使用 AWS DMS 从作为源端点的 MYSQL 和作为目标端点的 S3 迁移数据。
我想跟踪来自源的更新,所以在配置期间,我启用了 TimestampColumnName 属性(列名称:event_timestamp)。
在结果(如下所列)中,我得到了记录/事件的时间戳,但不是微秒精度。
我希望微秒级精度在此基础上构建序列逻辑。
我已经调查了源端点和目标的属性,但没有得到想要的结果。这是示例输出:
如果我缺少任何属性,有人可以看一下并提出建议吗?
输出格式:我在 S3 中的文件是 Parquet 。
最佳答案
不幸的是,AWS DMS S3 TimestampColumnName
为 从 MySQL 源加载更改数据捕获 (CDC) 添加的 DATETIME 列将有 strong>只有秒精度。
因为 MySQL 二进制日志中的事务时间戳只有几秒。
最简单的解决方案是向 MySQL 表添加新列 - timestamp with microsecond precision在插入或/和更新时设置默认值 automatically并将此列用作 event_timestamp
。
ts TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
另外,在 AWS DMS 中检查到 S3 setting ParquetTimestampInMillisecond
为 False
(或不存在/未设置,默认为 false)。
AWS DMS S3 TimestampColumnName
设置将带有时间戳的列添加到输出。
在“静态”读取中 - 它将生成当前时间戳:
For a full load, each row of this timestamp column contains a timestamp for when the data was transferred from the source to the target by DMS.
对于 CDC,它将从数据库事务日志中读取事务时间:
For a change data capture (CDC) load, each row of the timestamp column contains the timestamp for the commit of that row in the source database.
其精度将是数据库事务日志中的时间戳之一:
...the rounding of the precision depends on the commit timestamp supported by DMS for the source database.
CDC 模式本质上是 replication .应适当配置源数据库以写入此类事务日志。数据库写入此日志事务信息以及事务/提交时间戳。
对于 MySQL,这是 the binary log .和 MySQL binlog timestamp只有 32 位 - 只需几秒钟。
关于mysql - AWS DMS - MYSQL 上的 CDC 作为源端点的微秒级精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59638242/