java数据库学习之maxwell监听MySQL的Binlog

java数据库学习之maxwell监听MySQL的Binlog


maxwell监听MySQL的Binlog

1、下载解压

http://maxwells-daemon.io/quickstart/

2、修改MySQL服务器配置

$ vi my.cnf
[mysqld]
server_id=1
log-bin=master
binlog_format=row
1
2
3
4
5
6

3、创建账号给maxwell使用

mysql> CREATE USER 'maxwell'@'%' IDENTIFIED BY '123456';
mysql> GRANT ALL ON maxwell.* TO 'maxwell'@'%';
mysql> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%';
1
2
3
4

4、启动监听并输出到终端

bin/maxwell --user='maxwell' --password='123456' --host='127.0.0.1' --producer=stdout
1

也可以将配置写入配置文件

$ cat config.properties
log_level=info
producer=stdout
host=localhost
user=maxwell
password=123456
$ bin/maxwell --config config.properties
1
2
3
4
5
6
7
8
9

5、输出数据

mysql> insert into test.e set m = 4.2341, c = now(3), comment = 'I am a creature of light.';
{
"database":"test",
"table":"e",
"type":"insert",
"ts":1477053217,
"xid":23396,
"commit":true,
"position":"master.000006:800911",
"server_id":23042,
"thread_id":108,
"data":{
"id":1,
"m":4.2341,
"c":"2016-10-21 05:33:37.523000",
"comment":"I am a creature of light."
}
}

发表评论
留言与评论(共有 0 条评论)
   
验证码:

相关文章

推荐文章

'); })();