logstash配置日志kafka采集报Error connecting to node java.net.UnknownHostException
程序员文章站
2022-07-15 12:55:18
...
logstash可以将日志采集发送到kafka,写完logstash的配置文件,配置好input和output之后,却发现logstash下的logs文件夹中的logstash-plain.log文件一直在报
Error connecting to node ls-bi-test-vm-172-84:6667 (id: 1019 rack: /default-rack)
java.net.UnknownHostException: ls-bi-test-vm-172-84
at java.net.InetAddress.getAllByName0(InetAddress.java:1280) ~[?:1.8.0_181]
at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[?:1.8.0_181]
at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[?:1.8.0_181]
at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:104) ~[kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.currentAddress(ClusterConnectionStates.java:403) ~[kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.access$200(ClusterConnectionStates.java:363) ~[kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.ClusterConnectionStates.currentAddress(ClusterConnectionStates.java:151) ~[kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:949) [kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:291) [kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.producer.internals.Sender.sendProducerData(Sender.java:361) [kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:334) [kafka-clients-2.4.1.jar:?]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:244) [kafka-clients-2.4.1.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
百度了一下才知道,需要将配置的kafka地址加入到hosts文件当中,Linux系统,在 /etc/hosts 下,直接su切换root权限,增加
ip hostname
例:192.168.192.10 kafka.node1.com 后面的hostname要根据实际情况,其实通过日志文件可以发现,是kafka的客户端一直在报错,就是kafka没有连上,和logstash其实没什么关系