kafka常见错误

  1. Bootstrap broker ip:port (id: -1 rack: null) disconnected
  2. Could not find a ‘KafkaClient’ entry
  3. No serviceName defined in either JAAS or Kafka config

1 Bootstrap broker ip:port (id: -1 rack: null) disconnected

错误信息如下

[Consumer clientId=config-consumer-0, groupId=my_comsumer] Bootstrap broker ip:port (id: -1 rack: null) disconnected

错误原因

没有正确配置密码认证

正确配置如下

spring:
  kafka:
	properties:
      security:
        protocol: SASL_PLAINTEXT
      sasl:
        mechanism: SCRAM-SHA-256
        jaas:
          config: 'org.apache.kafka.common.security.scram.ScramLoginModule required username="username" password="password";'

2 No serviceName defined in either JAAS or Kafka config

错误配置security

# 错误示例
spring:
  kafka:
    bootstrap-servers: ip:port,ip:port,ip:port
    admin:
      client-id: test
    # 如果需要配置密码连接,这样配置是错误的
    security:
      protocol: SASL_PLAINTEXT
    jaas:
      enabled: true
      config: 'org.apache.kafka.common.security.scram.ScramLoginModule required username="username" password="password";'

密码连接配置方式见第一条。

3 Could not find a ‘KafkaClient’ entry in the JAAS configuration. System property ‘java.security.auth.login.config’ is not set

错误原因

密码连接配置错误

# 错误配置示例
spring:
  kafka:
    bootstrap-servers: ip:port,ip:port,ip:port
    admin:
      client-id: test
    # 如果需要配置密码连接,这样配置是错误的
    security:
      protocol: SASL_PLAINTEXT
    jaas:
      # 配置了security 不配置jaas的enabled 则会报该错误 ,密码连接正确配置见第一条
      # enabled: true 
      config: 'org.apache.kafka.common.security.scram.ScramLoginModule required username="username" password="password";'

4 Error while fetching metadata with correlation id 4 :

Error while fetching metadata with correlation id 4 : {CREATE_APP=UNKNOWN_TOPIC_OR_PARTITION}

错误原因之一 :topic不存在
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐