kafka1.0配置内外网访问
作者:互联网
1、修改hosts
vi /etc/hosts
## 添加内网地址映射到主机名
172.16.10.11 VM_11_11_centos VM_11_11_centos
2、修改kafka下config目录里的server.properties
vi ./server.properties
############################# Socket Server Settings #############################
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = security_protocol://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
## 第一处修改
listeners=PLAINTEXT://0.0.0.0:9092
# 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().
## 第二处修改
advertised.listeners=PLAINTEXT://124.171.127.180:9092
## 第三处修改(之前没有则添加这句)
advertised.host.name=VM_11_11_centos
3、重启kafka即可内外网同时访问
- 3.1启动zookeeper
./bin/zookeeper-server-start.sh ./config/zookeeper.properties >> /logs/zookeeper.file 2>&1 &
- 3.2启动kafka
nohup ./bin/kafka-server-start.sh ./config/server.properties >> /logs/kafka.file 2>&1 &
标签:11,访问,##,zookeeper,server,kafka,kafka1.0,listeners,内外 来源: https://blog.csdn.net/cocoaxian/article/details/115398407