MySQL+Maxwell+Kafka+ES+kibana实现MySQL日志分析
参考:
https://blog.youkuaiyun.com/qq_30921461/article/details/78320750
http://blog.sina.com.cn/s/blog_628cc2b70102xeha.html
https://www.jianshu.com/p/afc4dcc9ffb6
https://www.cnblogs.com/swordfall/p/8860941.html
https://www.cnblogs.com/moonandstar08/p/6556899.html
https://blog.youkuaiyun.com/sinat_28224453/article/details/51134978
https://blog.youkuaiyun.com/weixin_38441544/article/details/82382567
系统架构如图
1、Mysql配置
vi /etc/my.cnf
server-id=1
log-bin=mysql-bin(这一步开启binlog)
binlog_format=row
重启mysql:service mysqld restart
手工新建一个数据库maxwell(字符集utf8,也可以是别的名字,但必须和maxwell的config中的保持一致),maxwell将在该库内保存相关作业信息;如果不建,maxwell启动时会自己创建(如果config里面的数据库用户有足够权限的话)。
创建maxwell用户,拥有maxwell库全部权限,其他库对象的复制权限:
GRANT ALL on maxwell.* to 'maxwell'@'%' identified by '123456';
GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE on *.* to 'maxwell'@'%' ;
flush privileges;
mysql配置确认:
(1)mysql中配置binlog,开启后通过"show variables like 'log_bin';"查看是否ON的状态
(2)mysql中配置binlog的输出格式为row,开启后通过"show variables like 'binlog_format';"查看
(3)mysql开启log_slave_updates,该参数控制是否把所有的操作写入到binlog中,开启后通过"show variables like 'log_slave_updates';"查看
2、maxwell的安装及部署
下载: https://github.com/zendesk/maxwell/releases/download/v1.17.1/maxwell-1.17.1.tar.gz
解压:tar-xvf maxwell-1.17.1.tar.gz
修改配置:config.properties,增加mysql和kafka相关参数
log_level=info