The advertised.listeners property in server.properties needs to have the ip address that the broker is listening on.
For eg. advertised.listeners=PLAINTEXT://192.168.52.194:9092:9092 regards On Mon, Dec 25, 2017 at 12:20 AM, 刘闯 <l13936993...@163.com> wrote: > i‘ m a beginner of kafka. i usde kafka_2.11-0.9.0.1. my kafka built in > two virtual machinewhich ip are 52.193 and 52.194 > > when i use commonds both in 52.193 > ./kafka-console-producer.sh --broker-list 192.168.52.193:9092 --topic > shuaige > and > ./kafka-console-consumer.sh --zookeeper 192.168.52.195:2181 --topic > shuaige --from-beginning > > the message of producer was shown in consumer terminal. > > but when i use 52.193 as producer and 52.194 as consumer > ./kafka-console-producer.sh --broker-list 192.168.52.194:9092 --topic > shuaige > and > ./kafka-console-consumer.sh --zookeeper 192.168.52.195:2181 --topic > shuaige --from-beginning > > it shows WARN Error while fetching metadata with correlation id 0 : > {ttes=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) > [2017-12-25 15:22:19,571] WARN Error while fetching metadata with > correlation id 1 : {ttes=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients. > NetworkClient) > [2017-12-25 15:22:19,675] WARN Error while fetching metadata with > correlation id 2 : {ttes=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients. > NetworkClient) > > here is my configure,server.properties > # The id of the broker. This must be set to a unique integer for each > broker. > broker.id=0 > > ############################# Socket Server Settings > ############################# > > listeners=PLAINTEXT://:9092 > port=9092 > # The port the socket server listens on > #port=9092 > > # Hostname the broker will bind to. If not set, the server will bind to > all interfaces > #host.name=localhost > host.name=192.168.52.193 > # Hostname the broker will advertise to producers and consumers. If not > set, it uses the > # value for "host.name" if configured. Otherwise, it will use the value > returned from > # java.net.InetAddress.getCanonicalHostName(). > #advertised.host.name=<hostname routable by clients> > advertised.host.name = localhost > # The port to publish to ZooKeeper for clients to use. If this is not set, > # it will publish the same port that the broker binds to. > #advertised.port=<port accessible by clients> > advertised.port=9092 > # The number of threads handling network requests > num.network.threads=3 > > # The number of threads doing disk I/O > num.io.threads=8 > > # The send buffer (SO_SNDBUF) used by the socket server > socket.send.buffer.bytes=102400 > > # The receive buffer (SO_RCVBUF) used by the socket server > socket.receive.buffer.bytes=102400 > # The maximum size of a request that the socket server will accept > (protection against OOM) > socket.request.max.bytes=104857600 > > > ############################# Log Basics ############################# > > # A comma seperated list of directories under which to store log files > log.dirs=/tmp/kafka-logs > > # The default number of log partitions per topic. More partitions allow > greater > # parallelism for consumption, but this will also result in more files > across > # the brokers. > num.partitions=1 > > # The number of threads per data directory to be used for log recovery at > startup and flushing at shutdown. > # This value is recommended to be increased for installations with data > dirs located in RAID array. > num.recovery.threads.per.data.dir=1 > log.retention.hours=168 > message.max.byte=5242880 > default.replication.factor=2 > replica.fetch.max.bytes=5242880 > # A size-based retention policy for logs. Segments are pruned from the log > as long as the remaining > # segments don't drop below log.retention.bytes. > #log.retention.bytes=1073741824 > > # The maximum size of a log segment file. When this size is reached a new > log segment will be created. > log.segment.bytes=1073741824 > > # The interval at which log segments are checked to see if they can be > deleted according > # to the retention policies > log.retention.check.interval.ms=300000 > > ############################# Zookeeper ############################# > > # Zookeeper connection string (see zookeeper docs for details). > # This is a comma separated host:port pairs, each corresponding to a zk > # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002". > # You can also append an optional chroot string to the urls to specify the > # root directory for all kafka znodes. > #zookeeper.connect=localhost:2181 > zookeeper.connect=192.168.52.195:2181,192.168.52.196:2181,1 > 92.168.52.197:2181 > # Timeout in ms for connecting to zookeeper > zookeeper.connection.timeout.ms=6000 > > > > > ..thanks for you help > > -- http://khangaonkar.blogspot.com/