Kafka本身启动和相互通信没有问题,但是在使用Java API 模拟消费者连接到Kafka的时候出现报错
2022-03-03 09:31:22[Consumer clientId=consumer-1, groupId=test-consumer-group] Discovered group xxx:9092 (id: xxx rack: null) 2022-03-03 09:31:34[Consumer clientId=consumer-1, groupId=test-consumer-group] Group coordinator xxxt:9092 (id: xxx rack: null) is unavailable or invalid, will attempt rediscovery
原因分析:
我们可以注意一下控制台给出的域名地址,这个域名可能是因为解析问题或者限于远程服务器的安全策略做了转换
验证这个问题的办法,在windows开启telnet命令,在cmd中
telnet xxx 9092
发现是无法连接的
解决方案:
使用管理员权限手动在C:WindowsSystem32driversetchosts文件中添加映射
格式:
kafka服务器的ip 对应的域名
example:
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 192.168.98.101 hadoop01
在此连接到kafka,成功连接



