首页 > 解决方案 > Kafka Zookeeper 非标准端口

问题描述

我在我们的 kafka 部署 (kafka_2.12-2.3.0) 中看到 zookeeper 使用了一些未记录的端口。我的理解是 Kafka/Zookeeper 使用 9092、9093、2181、2888、3888。我们在 50000 端口范围内看到尝试连接。我们需要尽可能严格地配置防火墙。我是否错过了配置的东西或者 Kafka/Zookeeper 使用的其他非标准端口?

动物园管理员的输出

[2019-11-07 11:33:55,240] INFO Accepted socket connection from /192.168.0.52:52030 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2019-11-07 11:33:55,246] INFO Client attempting to establish new session at /192.168.0.52:52030 (org.apache.zookeeper.server.ZooKeeperServer)
[2019-11-07 11:33:55,250] INFO Established session 0x3004c34f9640003 with negotiated timeout 30000 for client /192.168.0.52:52030 (org.apache.zookeeper.server.ZooKeeperServer)
[2019-11-07 11:33:55,765] INFO Closed socket connection for client /192.168.0.52:52030 which had sessionid 0x3004c34f9640003 (org.apache.zookeeper.server.NIOServerCnxn)
[2019-11-07 11:34:16,499] INFO Accepted socket connection from /192.168.0.52:52038 (org.apache.zookeeper.server.NIOServerCnxnFactory)

zookeeper.properites

# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
server.1=192.168.0.52:2888:3888
server.2=192.168.0.53:2888:3888
server.3=192.168.0.54:2888:3888

服务器属性

############################# 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 = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://192.168.0.52: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://192.168.0.52:9092

标签: apache-kafkaapache-zookeeper

解决方案


您在日志中看到的是连接到 Zookeeper 的远程客户端的套接字(主机和端口)。

您将 Zookeeper 配置为侦听端口 2888,但连接到 Zookeeper 的客户端可以使用其任何(客户端)端口。

例如,在:

Accepted socket connection from /192.168.0.52:52038

这意味着来自 192.168.0.52:52038 的东西(可能是 Kafka 或 Zookeeper)连接到 Zookeeper。

Client                      Zookeeper
192.168.0.52:52038   ---->  192.168.0.52:2888

推荐阅读