开发者社区> 问答> 正文

安装 canal,已经写好了配置文件,结果一直提示空指针

在 CentOS 7.9 下面使用 docker-compose 的方式安装 canal-server 1.1.4,并将消息推送到 kafka,结果 kafka 没有接收到任何消息,查看 canal.log,提示空指针异常。

2022-02-10 01:53:59.871 [main] INFO com.alibaba.otter.canal.deployer.CanalLauncher - ## set default uncaught exception handler 2022-02-10 01:53:59.935 [main] INFO com.alibaba.otter.canal.deployer.CanalLauncher - ## load canal configurations 2022-02-10 01:53:59.954 [main] INFO com.alibaba.otter.canal.deployer.CanalStarter - ## start the canal server. 2022-02-10 01:53:59.980 [main] ERROR com.alibaba.otter.canal.deployer.CanalLauncher - ## Something goes wrong when starting up the canal Server: java.lang.NullPointerException: null at com.alibaba.otter.canal.deployer.CanalController.parseInstanceConfig(CanalController.java:438) ~[canal.deployer-1.1.4.jar:na] at com.alibaba.otter.canal.deployer.CanalController.initInstanceConfig(CanalController.java:413) ~[canal.deployer-1.1.4.jar:na] at com.alibaba.otter.canal.deployer.CanalController.(CanalController.java:88) ~[canal.deployer-1.1.4.jar:na] at com.alibaba.otter.canal.deployer.CanalStarter.start(CanalStarter.java:77) ~[canal.deployer-1.1.4.jar:na] at com.alibaba.otter.canal.deployer.CanalLauncher.main(CanalLauncher.java:115) ~[canal.deployer-1.1.4.jar:na]

docker-compose.yml

version: '3.1' services: canal-server: image: canal/canal-server:v1.1.4 container_name: canal-server restart: always ports: - 11111:11111 volumes: - ./conf/canal.properties:/home/admin/canal-server/conf/canal.properties - ./conf/test/instance.properties:/home/admin/canal-server/conf/test/instance.properties - ./logs/:/home/admin/canal-server/logs/

canal.properties

tcp, kafka, RocketMQ 这里选择kafka模式

canal.serverMode = kafka

解析器的线程数,打开此配置,不打开则会出现阻塞或者不进行解析的情况

canal.instance.parser.parallelThreadSize = 16

配置MQ的服务地址,这里配置的是kafka对应的地址和端口

canal.mq.servers = 127.0.0.1:9092

配置instance,在conf目录下要有test同名的目录,可以配置多个

canal.destinations = test

instance.properties

mysql serverId , v1.0.26+ will autoGen(自动生成,不需配置)

canal.instance.mysql.slaveId=0

position info

canal.instance.master.address=127.0.0.1:3306

在Mysql执行 SHOW MASTER STATUS;查看当前数据库的binlog

canal.instance.master.journal.name=mysql-bin.000006 canal.instance.master.position=4596

账号密码

canal.instance.dbUsername=canal canal.instance.dbPassword=Canal@123456 canal.instance.connectionCharset = UTF-8 #MQ队列名称 canal.mq.topic=canalTopic #单队列模式的分区下标 canal.mq.partition=0

原提问者GitHub用户UnityAlvin

展开
收起
后端老大 2023-04-26 16:35:18 241 0
1 条回答
写回答
取消 提交回答
  • conf目录下有好多.xml文件

    原回答者GitHub用户agapple

    2023-04-26 18:59:06
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载