1、下载解压
http://maxwells-daemon.io/quickstart/
2、修改MySQL服务器配置
$ vi my.cnf [mysqld] server_id=1 log-bin=master binlog_format=row
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'@'%';
4、启动监听并输出到终端
bin/maxwell --user='maxwell' --password='123456' --host='127.0.0.1' --producer=stdout
也可以将配置写入配置文件
$ cat config.properties log_level=info producer=stdout host=localhost user=maxwell password=123456 $ bin/maxwell --config config.properties
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." } }