解决方案:
vi kafka的server.properties
#添加下列参数
host.name=各自节点IP
advertised.listeners=PLAINTEXT://外网ip:外网映射port
解释说明:
例如:
内网主机IP | 映射名 | 默认端口号 | 外网映射IP | 外网映射端口号 |
192.168.1.1 | hadoop01 | 9092 | 192.168.56.78 | 19093 |
192.168.1.2 | hadoop02 | 19094 | ||
192.168.1.3 | hadoop03 | 19095 | ||
192.168.1.4 | hadoop04 | 19096 | ||
192.168.1.5 | hadoop05 | 19097 |
那么配置应该是:(建议不要用映射名来配置,IP最好)
#hadoop01的配置:
host.name=192.168.1.1
advertised.listeners=PLAINTEXT://192.168.56.78:9093
#hadoop02的配置:
host.name=192.168.1.2
advertised.listeners=PLAINTEXT://192.168.56.78:9094
#hadoop03的配置:
host.name=192.168.1.3
advertised.listeners=PLAINTEXT://192.168.56.78:9095
#hadoop04的配置:
host.name=192.168.1.4
advertised.listeners=PLAINTEXT://192.168.56.78:9096
#hadoop05的配置:
host.name=192.168.1.5
advertised.listeners=PLAINTEXT://192.168.56.78:9097
重启kafka集群,即可!