1、下载cancel
https://github.com/alibaba/canal/releases/tag/canal-1.1.5
2、修改conf文件夹下的canal.properties配置文件
canal.zkServers=localhost:2181
canal.serverMode = kafka
##################################################
######### Kafka #############
##################################################
kafka.bootstrap.servers = localhost:9092
3、修改conf/example文件夹下的instance.properties配置文件
在sql查询show binary logs语句得到binlog日志
canal.instance.master.address= localhost:3306
canal.instance.master.journal.name=mysql-bin.000001
canal.instance.master.position=156
# username/password
canal.instance.dbUsername=xxxx
canal.instance.dbPassword=xxxxx
canal.instance.filter.regex=db_mybatis.userProject #数据库名.表名,可多个
canal.mq.topic=canceltopic #消息队列的topic
4、启动
在bin目录下执行
./startup.sh
启动程序
注:MySQL需要创建新用户
mysql> CREATE USER canal IDENTIFIED BY '123456';
mysql> GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
mysql> FLUSH PRIVILEGES;
mysql> show grants for 'canal' ;