配置Kafka时启动控制台监听时报错(org.apache.kafka.clients.NetworkClient)

在配置好Kafka后启动控制台监听时,报错

[2019-01-16 07:57:16,084] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 1 : {music=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

我查了下资料,是因为Kafka的配置文件server.properties配置错了。

原来配置的如下:

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#port=9092
# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092

没有配置listeners = PLAINTEXT://your.host.name:9092。在配置集群的时候,必须设置,不然以后的操作会报找不到leader的错误 ,修改后的代码如下。

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://zhiyou02:9092
#port=9092
# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092

 

你可能感兴趣的:(Kafka)