maxwell: CDC从mysql 到 rabbitmq

2024-11-28

mysql配置

# /etc/my.cnf

[mysqld]

binlog_format=row

server_id=1 

log-bin=master

maxwell配置

docker run -it --rm zendesk/maxwell bin/maxwell --user=mysql数据库用户名 --password=mysql数据库密码 --host=mysqlIP地址或域名 --producer=rabbitmq --rabbitmq_host=rabbitmq域名或地址 --rabbitmq_user=rabbitmq用户名 --rabbitmq_pass=rabbitmq密码

示例数据

操作目标表时会队列会出现如下结构数据:

新增:

{"database":"xxx","table":"xxx","type":"insert","ts":1732497046,"xid":8296,"commit":true,"data": ...}

删除:

{"database":"xxx","table":"xxx","type":"delete","ts":1732497147,"xid":8569,"commit":true,"data": ... }

修改:

{"database":"xxx","table":"xxx","type":"update","ts":1732496729,"xid":7447,"commit":true,"data": ... }