Kafka 启动报错java.io.IOException: Can't resolve address.

阿里云上 部署 Kafka 启动报错 java.io.IOException: Can't resolve address.
本地调试的, 报错
需要在本地添加阿里云主机的 host 映射
 
linux kafka server 192.168.0.141 hostname bogon
在 windows
java 代码
 
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:
不能解析 bogon
kafka 连接原理
首先连接 192.168.0.141:9092
再连接返回的 host.name = bogon,
最后继续连接 advertised.host.name=bogon
解决办法
添加 window 解析
hosts 文件增加 
192.168.0.141 bogon
用 cmd ping bogon 试试如果可以 ping 通即可。