SpringBoot工程连远程Kafka报错UnknownHostException
2019-12-11 23:12:13.049 WARN 8604 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient: [Consumer clientId=consumer-1, groupId=test-hello-group] Error connecting to node test_host:9094 (id...
2019-12-11 23:12:13.049 WARN 8604 --- [ntainer#0-0-C-1] org.apache.kafka.clients.NetworkClient : [Consumer clientId=consumer-1, groupId=test-hello-group] Error connecting to node test_host:9094 (id: 2 rack: null)
java.net.UnknownHostException: test_host
at java.net.InetAddress.getAllByName0(Unknown Source) ~[na:1.8.0_231]
at java.net.InetAddress.getAllByName(Unknown Source) ~[na:1.8.0_231]
at java.net.InetAddress.getAllByName(Unknown Source) ~[na:1.8.0_231]
at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:104) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.currentAddress(ClusterConnectionStates.java:403) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.access$200(ClusterConnectionStates.java:363) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.ClusterConnectionStates.currentAddress(ClusterConnectionStates.java:151) ~[kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:943) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:288) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.trySend(ConsumerNetworkClient.java:474) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:252) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:233) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:224) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.consumer.KafkaConsumer.position(KafkaConsumer.java:1707) [kafka-clients-2.3.1.jar:na]
at org.apache.kafka.clients.consumer.KafkaConsumer.position(KafkaConsumer.java:1665) [kafka-clients-2.3.1.jar:na]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.seekPartitions(KafkaMessageListenerContainer.java:859) [spring-kafka-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.access$3700(KafkaMessageListenerContainer.java:460) [spring-kafka-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at
参考https://www.jianshu.com/p/ed9055bc68a6,
可能的错误
- kafka版本不对,现在这种方式只能支持0.10.x.x
- kafka配置没有对外开放host、port
- advertised.host.name、advertised.port
- broker-list配置的不对
检查发现config/server.properties中的advertised.listeners都没有配置。
于是在每个broker的server.properties中添加advertised.listeners=PLAINTEXT://192.168.31.151:9092
(端口随着自己broker的端口修改)
重启所有broker之后,不再报错。
更多推荐
所有评论(0)