使用 docker-compose 安装的一系列容器,启动 canal-server 之后,一直提示以下报错,一开始用的是 127.0.0.1 的 ip,后来知道它们都不在一个容器,所以更换成了内网 ip,结果还是报错。
kafka:2.12-2.6.0
canal-server:1.1.4
canal-server 的配置文件(部分内容)example.properties
##################################################
######### MQ #############
##################################################
canal.mq.servers = 192.168.3.60:9092
报错
2022-02-10 21:54:50.200 [pool-4-thread-1] ERROR com.alibaba.otter.canal.kafka.CanalKafkaProducer - java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
at com.alibaba.otter.canal.kafka.CanalKafkaProducer.produce(CanalKafkaProducer.java:215) ~[canal.server-1.1.4.jar:na]
at com.alibaba.otter.canal.kafka.CanalKafkaProducer.send(CanalKafkaProducer.java:179) ~[canal.server-1.1.4.jar:na]
at com.alibaba.otter.canal.kafka.CanalKafkaProducer.send(CanalKafkaProducer.java:120) ~[canal.server-1.1.4.jar:na]
at com.alibaba.otter.canal.server.CanalMQStarter.worker(CanalMQStarter.java:183) [canal.server-1.1.4.jar:na]
at com.alibaba.otter.canal.server.CanalMQStarter.access$500(CanalMQStarter.java:23) [canal.server-1.1.4.jar:na]
at com.alibaba.otter.canal.server.CanalMQStarter$CanalMQRunnable.run(CanalMQStarter.java:225) [canal.server-1.1.4.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
at org.apache.kafka.clients.producer.KafkaProducer$FutureFailure.(KafkaProducer.java:1150) ~[kafka-clients-1.1.1.jar:na]
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:846) ~[kafka-clients-1.1.1.jar:na]
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:784) ~[kafka-clients-1.1.1.jar:na]
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:671) ~[kafka-clients-1.1.1.jar:na]
at com.alibaba.otter.canal.kafka.CanalKafkaProducer.produce(CanalKafkaProducer.java:199) ~[canal.server-1.1.4.jar:na]
... 8 common frames omitted
Caused by: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
尝试过修改成内网ip
TimeoutException,你
telnet 192.168.3.60 9092
地址加端口看看通不通。大佬,容器内部,我不知道改怎么装telnet,CentOS。
进到容器里,通过:
yum update -y && yum install -y telnet
我感觉你的问题不会少,首先kafka启动,也要绑定容器ip,但是容器ip是动态的,不知道你怎么实现绑定的。
获取docker容器ip:
docker inspect --format='{{.NetworkSettings.IPAddress}}' kafka-raft-3.0.0
参考:
啊,谢谢大佬,我的安装方式,跟你的的确是不太一样,是我的确想的太简单了,其实docker我还没有系统的学习过,但是我又实在不想用传统方式安装,所以就硬上了docker。
我的配置文件是这么写的
version: '3.1' services: zookeeper: image: wurstmeister/zookeeper container_name: zookeeper restart: always volumes: - ./zookeeper-data:/data ports: - 2181:2181 kafka: image: wurstmeister/kafka:2.13-2.6.0 container_name: kafka ports: - 9092:9092 environment: KAFKA_ADVERTISED_HOST_NAME: kafka KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 restart: always volumes: - ./logs:/kafka - ./docker.sock:/var/run/docker.sock
你在容器外面(宿主机上),也可以telnet一下,看看是否能访问呀。
你的答案