Kafka started error java.io.IOException: Can not resolve address.

Kafka started deploying java.io.IOException error on Ali cloud: Can not resolve address.
Local debugging, error
Ali cloud host needs to be added in the local host mapping
 
linux kafka server 192.168.0.141 hostname bogon
In windows
java code
 
package myzookeeper;
 
import java.util.Properties;
 
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
 
public class myCustomer {
 
public static void  main(String[] args) {
Properties props = new Properties();  
        props.put("bootstrap.servers", "192.168.0.141:9092");  
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");  
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");  
        Producer producer = new KafkaProducer<>(props);  
        producer.send(new ProducerRecord<>("mytopic", "axxxx", "axxxx"));
        System.out.println("1");
        producer.close();  
}
}
 
 
报错 Error connecting to node 0 at bogon:9092:
Can not be resolved bogon
kafka connection principle
First connect 192.168.0.141:9092
Reconnection returned host.name = bogon,
Finally, continue to connect advertised.host.name = bogon
Solution
Add analytic window
hosts file to increase 
192.168.0.141 bogon
If the ping bogon try to use cmd ping.

Guess you like

Origin www.cnblogs.com/zeenzhou/p/10951126.html