我有一个kafka生产者项目通过Virtual box在Sandbox 2.4上实现,但自从在AWS EC2上实现了这个项目(使用Hortonworks cloudbreak)。这导致我升级到HDP 2.5,因此从kafka 9切换到kafka 10.我做了必要的依赖和IP(localhost)更改,但我得到java.net.ConnectException: Connection timed out: no further information
kafkaBroker内部ip为10.0.75.111,样本kafka生产者位于
之下public void initialise() {
Properties props = new Properties();
props.put("bootstrap.servers", "10.0.75.111:6667"); // replaced localhost
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
producer = new org.apache.kafka.clients.producer.KafkaProducer<Integer, String>(props);
}
Kafka听众是PLAINTEXT://localhost:6667
运行程序后,它将返回
下面的错误消息803862 [kafka-producer-network-thread | producer-14] DEBUG org.apache.kafka.clients.NetworkClient - Initiating connection to node -1 at 10.0.75.111:6667.
824863 [kafka-producer-network-thread | producer-14] DEBUG org.apache.kafka.common.network.Selector - Connection with /10.0.75.111 disconnected
java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:51)
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:73)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:309)
at org.apache.kafka.common.network.Selector.poll(Selector.java:283)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:260)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:229)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:134)
at java.lang.Thread.run(Thread.java:745)
824863 [kafka-producer-network-thread | producer-14] DEBUG org.apache.kafka.clients.NetworkClient - Node -1 disconnected.
感谢任何帮助,谢谢
答案 0 :(得分:1)
如果要将数据发送到AWS设置群集,则需要使用外部IP地址。但是,如果从网络运行,则可以同时使用两者。
在您的情况下,您似乎从网络外部运行。尝试从内部使用来自外部/内部的公共IP运行。这应该让你去。