目录
Apache Hadoop生态-目录汇总-持续更新
1:insert一条数据
2:insert多条数据
3:update语句
4:delete
系统环境:centos7
Java环境:Java8
mysql> insert into test values(1,'aaa');
Maxwell数据格式json
{
"database": "test_maxwell", --库名
"table": "test", --表名
"type": "insert", --数据更新类型
"ts": 1637244821, --操作时间
"xid": 8714, --操作 id
"commit": true, --提交成功
"data": { --数据
"id": 1,
"name": "aaa"
}
出现了 3 条 json日志,说明 maxwell 是以数据行为单位进行日志的采集的
同时插入多条数据, 前面的状态都是等待提交,xoffset, 最有一条才是提交:"commit":true
mysql> INSERT INTO test VALUES(2,'bbb'),(3,'ccc'),(4,'ddd');
{"database":"test_maxwell","table":"test","type":"insert","ts":1637245127,"xid":9129,"xoffset":0,"data":{"id":2,"name":"bbb"}}
{"database":"test_maxwell","table":"test","type":"insert","ts":1637245127,"xid":9129,"xoffset":1,"data":{"id":3,"name":"ccc"}}
{"database":"test_maxwell","table":"test","type":"insert","ts":1637245127,"xid":9129,"commit":true,"data":{"id":4,"name":"ddd"}}
mysql> update test set name='abc' where id =1;
{
"database": "test_maxwell",
"table": "test",
"type": "update",
"ts": 1637245338,
"xid": 9418,
"commit": true,
"data": { --修改后的数据
"id": 1,
"name": "abc"
},
"old": { --修改前的数据
"name": "aaa"
}
}
与insert单条格式基本一致,只有type不同
mysql> DELETE FROM test WHERE id =1;
{
"database": "test_maxwell",
"table": "test",
"type": "delete",
"ts": 1637245630,
"xid": 9816,
"commit": true,
"data": {
"id": 1,
"name": "abc"
}
}