Error connecting to node kafka1:9092 (id: 0 rack: null) ,marathon docker镜像添加hosts
业务需求为处理数据推到另一台机器得kafka中 kafka配置地址为ip加端口形式 但实际试用环境中报错2021-07-27 05:18:18.366WARN 1 --- [-b726640983cc-1] org.apache.kafka.clients.NetworkClient: [Producer clientId=nettyKafkaProducer98b74cc5-dfb5-4d68-
·
业务需求为处理数据推到另一台机器得kafka中 kafka配置地址为ip加端口形式 但实际试用环境中报错
2021-07-27 05:18:18.366 WARN 1 --- [-b726640983cc-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=nettyKafkaProducer98b74cc5-dfb5-4d68-9a14-b726640983cc-1] Error connecting to node kafka1:9092 (id: 0 rack: null)
java.net.UnknownHostException: kafka1: Name or service not known
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_111]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_111]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_111]
at java.net.InetAddress.getAllByName0(InetAddress.java:1276) ~[na:1.8.0_111]
at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[na:1.8.0_111]
at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[na:1.8.0_111]
at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:110) ~[kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.currentAddress(ClusterConnectionStates.java:403) ~[kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.access$200(ClusterConnectionStates.java:363) ~[kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.ClusterConnectionStates.currentAddress(ClusterConnectionStates.java:151) ~[kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:958) [kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:294) [kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.producer.internals.Sender.sendProducerData(Sender.java:351) [kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:324) [kafka-clients-2.6.0.jar!/:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:240) [kafka-clients-2.6.0.jar!/:na]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
配置端其实并没有用kafka1:9090 而是直接使用ip加端口得配置,所以应该是kafka端做了限制需要试用host得模式去推送
百度了好久 处理方案多是添加hosts 但发布环境特殊 是基于mesos+marathon得docker部署环境
无法在docker run得时候 使用–addhosts
现记录下解决方案
marathonjson中添加如下配置 启动时便回添加相应host 同理可添加dns-search
"container": {
"type": "DOCKER",
"docker": {
"network": "HOST",
"image": "your/image",
"parameters": [
{ "key": "add-host", "value": "host:ip" },
{ "key": "dns-search", "value": "url" }
]
}
}
更多推荐
已为社区贡献3条内容
所有评论(0)