kafka你不知道的firstblood坑

1、kafka服务器配置问题,咱们先看一段kafka的配置描述

Hostname and port the broker will advertise to producers and consumers. If not set,
it uses the value for “listeners” if configured. Otherwise, it will use the value
returned from java.net.InetAddress.getCanonicalHostName().

在我们使用默认配置时hostname和advertise.host.name是被注释掉的,所以系统会调用InetAddress.getCanonicalHostName()方法获取,这个值一般是localhost,如果kafka的消费者或者生产者那到这个localhost只能去本机kafka服务器消费或生产消息,所以当我们在本机使用时没问题,而一旦连的是远程的kafka服务器,使用localhost去消费本机的消息,这肯定是不可以的,感觉kafka这样设计又一点不太方便。所以我们在使用远程kafka服务器时应该把…/kafka/config/service.properties 中的advertised.host.name=<远程kafka服务器的ip地址>。

2、

猜你喜欢

转载自blog.csdn.net/espace123123/article/details/90178516