kafka前段时间没有问题,这两天总是报错

Empress ° 发表于: 2019-05-16   最后更新时间: 2022-02-18 19:51:07   4,683 游览

2019-05-16 14:28:40.661 WARN [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient.warn: 246 -------[Producer clientId=producer-1] Error while fetching metadata with correlation id 4254 : {d_android_190741b4-89a5-4f8c-832a-0b9e73ff8304_log_1=INVALID_REPLICATION_FACTOR, d_android_6ce83310-a25b-4255-bb69-877938bc8776_log_1=INVALID_REPLICATION_FACTOR, d_android_fb4e048b-47ce-4458-b41d-51b34c5571fe_log_1=INVALID_REPLICATION_FACTOR, d_android_b31fa4a8-245f-40ab-bbb9-7486295e2149_log_1=INVALID_REPLICATION_FACTOR}
2019-05-16 14:28:40.764 WARN [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient.warn: 246 -------[Producer clientId=producer-1] Error while fetching metadata with correlation id 4255 : {d_android_190741b4-89a5-4f8c-832a-0b9e73ff8304_log_1=INVALID_REPLICATION_FACTOR, d_android_6ce83310-a25b-4255-bb69-877938bc8776_log_1=INVALID_REPLICATION_FACTOR, d_android_fb4e048b-47ce-4458-b41d-51b34c5571fe_log_1=INVALID_REPLICATION_FACTOR, d_android_b31fa4a8-245f-40ab-bbb9-7486295e2149_log_1=INVALID_REPLICATION_FACTOR}
2019-05-16 14:28:40.867 WARN [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient.warn: 246 -------[Producer clientId=producer-1] Error while fetching metadata with correlation id 4256 : {d_android_190741b4-89a5-4f8c-832a-0b9e73ff8304_log_1=INVALID_REPLICATION_FACTOR, d_android_6ce83310-a25b-4255-bb69-877938bc8776_log_1=INVALID_REPLICATION_FACTOR, d_android_fb4e048b-47ce-4458-b41d-51b34c5571fe_log_1=INVALID_REPLICATION_FACTOR, d_android_b31fa4a8-245f-40ab-bbb9-7486295e2149_log_1=INVALID_REPLICATION_FACTOR}

发表于 2019-05-16
添加评论

网上说这个错误需要修改kafka的配置文件。但是更改了之后,就会报连接不上Zookeep

半兽人 -> Empress ° 5年前

描述信息太少,核心的配置也没贴。

Empress ° -> 半兽人 5年前

application.yml中配置:

spring
   kafka:
      bootstrap-servers: localhost:9092

kafka server.properties中没有更改或增加任何配置

代码中:

private void send(String topic, String key, String data) {
       kafkaTemplate.send(topic, key, data);
   }

单纯用了send方法,自己自定义了主题。

运行项目:现在经常报:

异常一:

2019-05-16 18:00:58.326 ERROR [http-nio-9202-exec-64] o.springframework.kafka.support.LoggingProducerListener.onError: 76 ---------Exception thrown when sending a message with key='1558000798326' and payload='{"content":"ok","level":1,"operation":"login","ts":1558000797,"user":"admin"}' to topic d_android_078cc8fb-b3ca-4c61-81e1-ee73bc6d9094_log_1:
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

异常二:

2019-05-16 18:00:57.899 WARN [kafka-producer-network-thread | producer-1] org.apache.kafka.clients.NetworkClient.warn: 246 ---------[Producer clientId=producer-1] Error while fetching metadata with correlation id 45735 : {d_android_bdab2e6e-8e1f-499d-9428-87d5160375a7_log_1=INVALID_REPLICATION_FACTOR, d_android_05e5a80e-3912-40f3-a9f9-ba0751d86daa_log_1=INVALID_REPLICATION_FACTOR, d_android_4a0e8d8e-8ea0-40b6-9501-2b94aee4f1c7_log_1=INVALID_REPLICATION_FACTOR, d_android_078cc8fb-b3ca-4c61-81e1-ee73bc6d9094_log_1=INVALID_REPLICATION_FACTOR, d_android_d85eed68-1396-4d65-a867-6cca533f2e62_log_1=INVALID_REPLICATION_FACTOR, d_android_0419f16a-e330-45e0-a3ad-df26194ce7f6_log_1=INVALID_REPLICATION_FACTOR, d_android_d0a1cf43-eb44-4286-a0ed-464b3efde003_log_1=INVALID_REPLICATION_FACTOR, d_android_c23805b6-be91-44e7-8875-89342127ccef_log_1=INVALID_REPLICATION_FACTOR}

项目偶尔可以正常使用,但是后台日志经常会报这种错误

半兽人 -> Empress ° 5年前

你一直在本地调用吗?

半兽人 -> 半兽人 5年前

1、你先查下集群状态。
2、生产者消费者代码和kafka都在同一台机器吗?

Empress ° -> 半兽人 5年前

zookeep 用的是单机的 kafka配置我也是配的单机的
代码放在项目里面 项目和kafka,zookeep 都是放在服务器上的

你的答案

查看kafka相关的其他问题或提一个您自己的问题