来自Kafka连接器容器的java Access Redis容器获取RedisConnectionException
我的任务是在docker容器中运行Kafka连接器,当我尝试在主机上运行连接器时,一切正常,但在容器中失败。我知道有很多类似的问题(我是卡夫卡和Redis的新手,真的找不到解决方案)。我尝试了很多解决方案,从这个答案Connecting a Redis container with another container (Docker)得出的算法看起来真的很神奇,但在中对我不起作用,我不明白为什么
在Docker应用程序中,它为我提供堆栈跟踪:
错误WorkerSinkTask{id=kafka-connect-redis-0}任务引发了一个未捕获且不可恢复的异常(org.apache.kafka.connect.runtime.WorkerTask:186) 伊奥。莴苣果心RedisConnectionException:无法连接到redis主机:6379 在木卫一。莴苣果心重新连接异常。创建(RedisConnectionException.java:78) 由:io引起。内蒂。频道AbstractChannel$AnnotatedConnectionException:连接被拒绝:redis master/172.22.0.3:6379 原因:java。网ConnectException:连接被拒绝 在阳光下。尼奥。索克坦林普尔。checkConnect(本机方法)
我的Redis配置:
replicaof redis-master 6379
# bind 0.0.0.0
protected-mode no
我的连接器属性文件
name=kafka-connect-redis
topics=bots
tasks.max=1
connector.class=com.github.jcustenborder.kafka.connect.redis.RedisSinkConnector
key.converter=org.apache.kafka.connect.storage.StringConverter
key.converter.schemas.enable=false
value.converter=org.apache.kafka.connect.storage.StringConverter
#offset.storage.file.filename=/tmp/connection/redis/connect.offsets
redis.hosts=redis-master,redis-slave-1,redis-slave-2
use.record.key=true
我的码头工人撰写:
redis-master:
image: redis
container_name: redis-m
# ports:
# - 6379:6379
volumes:
- ./clear-redis.sh:/bin/clear-redis.sh
command: bash -c "chmod +x /bin/clear-redis.sh && bash /bin/clear-redis.sh"
redis-slave-1:
image: redis
container_name: redis-s-1
# ports:
# - 7000:6379
volumes:
- ./config/redis:/usr/local/etc/redis/
command: redis-server /usr/local/etc/redis/redis.conf
redis-slave-2:
image: redis
container_name: redis-s-2
# ports:
# - 7001:6379
volumes:
- ./config/redis:/usr/local/etc/redis/
command: redis-server /usr/local/etc/redis/redis.conf
kafka-connect-redis:
image: confluentinc/cp-kafka-connect:5.5.1
container_name: connect-redis
hostname: kafka-connect-redis
ports:
- 8086:8086
volumes:
- ./connection/connectors/kafka-connect-redis/lib/:/etc/kafka-connect/jars/
- ./connection/connectors/kafka-connect-redis/redis-sink.properties:/usr/share/redis-sink.properties
- ./connection/connect-standalone-2.properties:/etc/connect-standalone-2.properties
- ./connection/run-redis.sh:/bin/run-redis.sh
depends_on:
- zoo
- kafka1
- kafka2
- kafka3
- redis-master
- redis-slave-1
- redis-slave-2
command: bash -c "chmod +x /bin/run-redis.sh && ./bin/run-redis.sh"
共 (0) 个答案