大数据监控binlog组件之maxwell组件:
Maxwell是什么玩意?下面我给大家简单介绍一下,并和canal做一个简单的对比:
Maxwell:(Zendesk公司)--(服务端+客户端)
官方地址:
http://maxwells-daemon.io/
Github地址:
https://github.com/zendesk/maxwell
具体实践Demo:
https://blog.csdn.net/wangpei1949/article/details/81556589
官网上贼详细,在此我就不搬砖了哈!!!
小结一下:
Maxwell 是mysql+kakfa的缩写,这个组件是老外写的,专门为了解决mysql binlog到kafka而做的中间件,为了解决这个binlog解析及迁移的问题。之前我一直对canal不是很理解,就是因为网上有一些傻大个子说,canal不支持写入kafka,我想说一句扯犊子,明明是支持的,好吗?maxwell基本上不用配置,就可以使用了。监控binlog输出json格式 的数据。canal相对于Maxwell,前期可能在kafka支持这一块比较弱,但是后面已经越来越完善了。在此我说一句canal通过配置也是可以直接将binlog日志输出到kafka的,Maxwell是天生支持的,这个就不说了。具体的kafka输出的json日志,见最下面json格式:
Maxwell和canal 对比:
|
Canal(服务端) |
Maxwell(服务端+客户端) |
语言 |
Java |
Java |
活跃度 |
活跃 |
活跃 |
HA |
支持 |
定制(不支持HA,支持断点还原的功能) |
数据落地 |
定制 |
落地到kafka |
分区 |
支持 |
支持 |
Bootstrap(引导,全量) |
不支持 |
支持(select * 初始化操作) |
数据格式 |
格式自由 |
Json(格式固定) |
文档 |
详细 |
详细 |
随机读 |
支持 |
支持 |
canal的json输出到kafka的格式:
为什么不用原生的输出,原生的不好解析哦!
canal:
{"data":[{"id":"4","name":"4"}],"database":"fwj-hi","es":1550483268000,"id":3,"isDdl":false,"mysqlType":{"id":"bigint(20)","name":"varchar(20)"},"old":null,"pkNames":null,"sql":"","sqlType":{"id":-5,"name":12},"table":"t_user","ts":1550483268276,"type":"INSERT"}
{"data":[{"id":"4","name":"5"}],"database":"fwj-hi","es":1550483272000,"id":4,"isDdl":false,"mysqlType":{"id":"bigint(20)","name":"varchar(20)"},"old":[{"name":"4"}],"pkNames":null,"sql":"","sqlType":{"id":-5,"name":12},"table":"t_user","ts":1550483272311,"type":"UPDATE"}
{"data":[{"id":"4","name":"5"}],"database":"fwj-hi","es":1550483276000,"id":5,"isDdl":false,"mysqlType":{"id":"bigint(20)","name":"varchar(20)"},"old":null,"pkNames":null,"sql":"","sqlType":{"id":-5,"name":12},"table":"t_user","ts":1550483276123,"type":"DELETE"}
Maxwell输出:(这个看起来更清楚些)
{"database":"fwj-hi","table":"t_flink_user","type":"insert","ts":1546500534,"xid":15180,"commit":true,"data":{"user_id":1004,"name":"校招"}}
{"database":"fwj-hi","table":"t_flink_user","type":"update","ts":1546502558,"xid":15471,"xoffset":0,"data":{"user_id":1004,"name":"事务测试1"},"old":{"name":"校招"}}
{"database":"fwj-hi","table":"t_flink_user","type":"delete","ts":1546502558,"xid":15471,"commit":true,"data":{"user_id":1004,"name":"事务测试1"}}