0
votes

I have two machines localhost and 192.168.1.110 to run two independent single machine kafka.

(1)At localhost, I run:

➜ kafka_2.11-0.10.0.0 bin/kafka-console-producer.sh --broker-list 192.168.1.110:9092 --topic test this is a message [2016-08-24 18:15:27,441] ERROR Error when sending message to topic test with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback) org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for test-0

Why message can't be sent to broker at 192.168.1.110? could I use broker ip directly in consumer or producer? If I could only use hostname, does this relate to advertised.host.name? then how to set up advertised.host.name? does this host name should be globally resolvable(could I use /etc/hosts to resolve the host name?)

(2) I edited /etc/hosts to let localhost point to 192.168.1.110, then I run: ➜ kafka_2.11-0.10.0.0 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

and I could successfully sent messages to 192.168.1.110 and consumed the messages there.

(3)I edited /etc/hosts to let rrlocalhost point to 192.168.1.110, then I run: ➜ kafka_2.11-0.10.0.0 bin/kafka-console-producer.sh --broker-list rrlocalhost:9092 --topic test

then I sent messages to rrlocalhost, there is the same error as in (1).

1

1 Answers

1
votes

Definitely you can use ip address directly.

broker config advertised.host.name will be registered in zookeeper, and producer and consumer will fetch them as cluster metadata. If you config it using local nick name, producer and consumer will be trouble to communicate with it.