canal安装及配置
提前准备好canal软件包
注意:canal解压后是散的,故需要解压在具体的canal目录上
module>mkdir canal
tar -zxvf canal.deployer-1.1.4.tar.gz -C /opt/module/canal
1、设置安全级别
mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0
2、分配一个账号(canal)可以操作数据库
mysql> GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%' IDENTIFIED BY 'canal' ;
canal监控抓取MySQL数据
1、修改canal/conf/canal.properties
canal.serverMode = kafka
canal.mq.servers = hadoop102:9092,hadoop103:9092,hadoop104:9092
2、修改conf/example/instance.properties
canal.instance.master.address=hadoop102:3306
canal.instance.dbUsername=canal
canal.instance.dbPassword=canal
canal.mq.topic=ods_base_db_c
3、启动canal
canal>bin/startup.sh
4、启动kafka消费客户端测试
提前开启zookeeper、kafak
bin/kafka-console-consumer.sh --bootstrap-server hadoop102:9092 --topic ods_base_db_c
5、操作数据库,查看kafak消费客户端的效果