Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka Consumer Error - xxxx nodename nor servname provided, or not known

When running the console consumer using the following command

$ ~/project/libs/kafka_2.9.2-0.8.1.1/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic customerevents --autocommit.interval.ms 100 --group customereventsgroup

i get the following error

Exception in thread "main" java.net.UnknownHostException: HQSML-142453: HQSML-142453: nodename nor servname provided, or not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:107)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:128)
    at kafka.consumer.Consumer$.create(ConsumerConnector.scala:89)
    at kafka.consumer.ConsoleConsumer$.main(ConsoleConsumer.scala:178)
    at kafka.consumer.ConsoleConsumer.main(ConsoleConsumer.scala)
Caused by: java.net.UnknownHostException: HQSML-142453: nodename nor servname provided, or not known
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
    at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
    ... 5 more

Now this command worked fine when connected to the work network but not when running from my home network.

Checking the hostname of the system I do get the correct response

$hostname
HQSML-142453
$

After reading a bit, I noticed that the Kafka server configuration has the following

# 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=HQSML-142453

which i updated to include my hostname but that didn't seem to help. Any ideas on what could be the problem here.

I know this is some networking interface related but cannot narrow it down to what it is.

config: Yosemite, osx jdk 7, kafka v0.8.1.1

like image 940
panksdmz Avatar asked Mar 18 '23 06:03

panksdmz


1 Answers

Try the following;

Run

ping HQSML-142453

If the ping is not working that means you don't have have the hostname configured in /etc/hosts or in your router DNS. So you must either edit the /etc/hosts and map your HQSML-142453 name to the IP address where your kafka is running or map it in your router DNS.

Mapping must look like the following in /etc/hosts;

127.0.0.1  HQSML-142453
like image 115
shazin Avatar answered Apr 06 '23 02:04

shazin