1、安装
1、下载安装包:https://github.com/alibaba/canal/releases/download/canal-1.1.5/canal.deployer-1.1.5.tar.gz
2、tar -zxvf -C 指定目录解压
2、配置修改
1、全局配置(修改canal.properties)
canal.mq.database.hash = false -- 同步分库分表的数据,使分库分表数据在一个分区中
kafka.bootstrap.servers= xxx:9092 设置kafka地址
kafka.retries = 1 重试次数
2、设置实例
canal.instance.master.address=xxx -- 数据库实例地址
canal.instance.dbUsername= -- 读取binlog的账户
canal.instance.dbPassword= --读取binlog的密码
canal.instance.filter.regex=fintech_settle_\\d+\\.tb_settle_apply,fintech_settle\\.tb_settle_clearing,fintech_settle\\.tb_settle_detail 指定监听表(使用正则)
canal.instance.filter.black.regex= --指定监听黑名单
canal.mq.topic=a_default_topic (最好配置一个canal.mq.topic作为默认的topic,在实践中发现,有一些mysql schema的binlog也会读进来(建表语句,grant语句等),如果没有这个默认的topic,会报找不到分区的错误,从而导致canal停止写入)
canal.mq.dynamicTopic=doris_topic_ods_fintech_settle_tb_settle_apply:fintech_settle\\.tb_settle_apply,doris_topic_ods_fintech_settle_tb_settle_clearing:fintech_settle\\.tb_settle_clearing,doris_topic_ods_fintech_settle_tb_settle_detail:fintech_settle\\.tb_settle_detail --为表指定topic
canal.mq.partitionHash=fintech_settle\\.tb_settle_apply:trade_order_no,fintech_settle\\.tb_settle_clearing:trade_order_no,fintech_settle\\.tb_settle_detail:settle_request_no --指定hash主键
canal.mq.dynamicTopicPartitionNum=doris_topic_ods_fintech_settle_tb_settle_apply:5,doris_topic_ods_fintech_settle_tb_settle_clearing:5,doris_topic_ods_fintech_settle_tb_settle_detail:5
-- 指定topic分区数
3、开启canal,查看logs,看是否有报错
1、 bin/startup.sh -- 开启canal
2、cd logs/canal
3、cat canal.log