返回到文章

采纳

编辑于 4年前

java访问docker-compose启动的kafka,出现超时

kafka

原本用着很好的kafka,突然超时。kafka部署情况:单机版部署单个kafka服务,不涉及集群,用docker-compose启动。

查询docker日志,报如下错误

ERROR [KafkaApi-1003]
Number of alive brokers '0' does not meet the required replication factor '1' for the offsets topic (configured via 'offsets.topic.replication.factor'). 
This error can be ignored if the cluster is starting up and not all brokers are up yet. (kafka.server.KafkaApis)

百度说是更改kafka备份数量,及在docker-compose.yml文件增加最后一行配置

environment:
KAFKA_ADVERTISED_HOST_NAME: xx.xx.x.x
KAFKA_ADVERTISED_PORT: 9192
KAFKA_PORT: 9192
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_DELETE_TOPIC_ENABLE: "true"
KAFKA_NUM_PARTITIONS: 1
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

更改后重启kafka容器,还是连接超时,博主可以给看下怎么回事么。

试了很多办法都不凑效。