由于kafka运行是通过docker镜像的方式运行的,而且zookeeper外部的客户端也可以连接上zookeeper就排除了,zookeeper的异常情况,那么剩下的只可能是kafka运行的命令出问题了,我之前的运行命令如下:
docker run -dit --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=106.14.132.94:2181 \
-e KAFKA_ADVERTISED_HOST_NAME=106.14.132.94 \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://106.14.132.94:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-v /etc/localtime:/etc/localtime \
-t wurstmeister/kafka
把监听的0.0.0.0改成服务器ip地址
docker run -dit --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=106.14.132.94:2181 \
-e KAFKA_ADVERTISED_HOST_NAME=106.14.132.94 \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://106.14.132.94:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://106.14.132.94:9092 \
-v /etc/localtime:/etc/localtime \
-t wurstmeister/kafka
但是还是有出错的情况:
Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
Host is unreachable (org.apache.zookeeper.ClientCnxn)
[2021-11-16 15:20:11,821] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Clien 《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》无偿开源 威信搜索公众号【编程进阶路】 t environment:java.compiler= (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:os.version=5.10.60-9.al8.x86_64 (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:user.dir=/ (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:os.memory.free=973MB (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:os.memory.max=1024MB (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,821] INFO Client environment:os.memory.total=1024MB (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,838] INFO Initiating client connection, connectString=106.14.132.94:2181 sessionTimeout=18000 watcher=kafka.zookeeper.ZooKeeperClient Z o o K e e p e r C l i e n t W a t c h e r ZooKeeperClientWatcher ZooKeeperClientWatcher@4466af20 (org.apache.zookeeper.ZooKeeper)
[2021-11-16 15:20:11,857] INFO jute.maxbuffer value is 4194304 Bytes (org.apache.zookeeper.ClientCnxnSocket)
[2021-11-16 15:20:11,864] INFO zookeeper.request.timeout value is 0. feature enabled= (org.apache.zookeeper.ClientCnxn)
[2021-11-16 15:20:11,871] INFO [ZooKeeperClient Kafka server] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
[2021-11-16 15:20:21,879] INFO Opening socket connection to server 106.14.132.94/106.14.132.94:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2021-11-16 15:20:21,885] INFO Socket error occurred: 106.14.132.94/106.14.132.94:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
奇怪的是zookeeper的节点有kafka相关的数据了
SASL全称Simple Authentication and Security Layer,是一种用来扩充C/S模式验证能力的机制。
[](()三、解决方案
网上百度了一堆没用的,我一一列举出来
第一个说是通过官网发现,在zookeeper 3.4.5之前,sasl认证是没有办法规避的,在3.4.6版本后修复了这个bug,因为不停的去检测认证虽然对功能没有什么影响,但是比较耗费服务器性能,比较占用容器资源。zk升级到3.4.6+的版本,可我的版本是zookeeper-3.4.13,肯定是符合的,无效。
第二个说是让zookeeper绕过sasl安全机制,禁用sasl认证,直接向系统获取资源。在conf目录下的zoo.cfg文件添加配置,zookeeper.sasl.client=false,然后重启zookeeper,亲身试过,无效。
第三个说是端口开放的问题,防火墙啊,入口和出口规则限制啊,这些符合,因为我可以通过客户端工具连接zookeeper,所以不存在端口问题,无效。
第四个说是给zookeeper做安全配置,但是我的初衷是对Kafka客户端使用SASL身份验证,但不要求kafka对Zookeeper进行SASL身份验证,我不关心kafka < - > zookeeper之间的安全校验问题,我就想单纯的通过docker进行运行kafka,可以让我进到容器内部进行测试发送消息。所以我还在寻找绕开sasl认证的办法,通过在apache bug管理官网:[https://issues.apache.org/jira/browse/ZOOKEEPER-1657]((),我大致看了看还是和上面类似的解决方案。
大致的意思就跟第一个说的差不多,不停的去检测认证虽然对功能没有什么影响,但是比较耗费服务器性能,比较占用容器资源。
下面的解决方案也如出一辙。
除此之外,还发现了一篇帖子的解决方案也大体相同
只不过我都尝试过,发现都不起效果。
然后我去查看有关SASL配置项
X509AuthenticationProvider.superUser:Java系统属性:zookeeper.X509AuthenticationProvider.superUser)支持SSL的方法,使ZooKeeper集合管理员能够以“超级”用户身份访问znode层次结构。当此参数设置为X500主体名称时,只有具有该主体的经过身份验证的客户端才能绕过ACL检查并拥有所有znode的完全权限。
zookeeper.superUser:Java系统属性:zookeeper.superUser)与zookeeper.X509AuthenticationProvider.superUser类似,但对于基于SASL的登录是通用的。它存储可以作为“超级”用户访问znode层次结构的用户的名称。
看了这些配置,发现并没什么作用。到这里我基本放弃了绕开sasl认证的办法了,网上也找不到更多有用的消息,还不如老老实实的配置安全认证,这里我参考了二篇博文,第一篇是集群模式的:[https://blog.csdn.net/sdksdk0/article/details/95336382]((),第二篇是[https://www.orchome.com/553](()。又熬到快十二点半了,熬不动了,睡觉睡觉,希望有大神可以帮忙解决这个绕开sasl认证的问题,至于权限认证的问题,等也时间再慢慢实现。这里我提供kafka和zookeeper的启动命令给大神作参考。
具体实现可参考:[https://liaozhiwei.blog.csdn.net/article/details/120716913](()
早上起床接着排查
第五个说的是zookeeper客户端 和服务器连接时版本问题,不过我并没有用程序连接,无效
第六个说的是zookeeper服务器主动断开与客户端的连接问题,修改配置,无效
这个时候我去看了看zookeeper的日志信息,发现也报错了
这个时候,我将之前改过的配置都还原,把原有的镜像都删除,重新启动docker运行镜像
kafka
docker run -dit --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=106.14.132.94:2181 \
-e KAFKA_ADVERTISED_HOST_NAME=106.14.132.94 \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://106.14.132.94:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://106.14.132.94:9092 \
-v /etc/localtime:/etc/localtime \
-t wurstmeister/kafka
zookeeper
docker run -dit --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 --name zookeeper \
-p 2181:2181 \
-v /etc/localtime:/etc/localtime \
-t wurstmeister/zookeeper
然后发现zookeeper的错误信息日志
2021-11-18 00:11:05,537 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@922] - Refusing session request for client /114.87.234.228:57390 as it has seen zxid 0x7 our last zxid is 0x0 client must try another server
2021-11-18 00:11:05,537 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57390 (no session established for client)
2021-11-18 00:11:07,162 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57843
2021-11-18 00:11:07,162 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@922] - Refusing session request for client /114.87.234.228:57843 as it has seen zxid 0x7 our last zxid is 0x0 client must try another server
2021-11-18 00:11:07,163 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57843 (no session established for client)
2021-11-18 00:11:09,310 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57534
2021-11-18 00:11:09,318 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@922] - Refusing session request for client /114.87.234.228:57534 as it has seen zxid 0x7 our last zxid is 0x0 client must try another server
2021-11-18 00:11:09,318 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57534 (no session established for client)
2021-11-18 00:11:10,942 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57699
2021-11-18 00:11:10,943 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@922] - Refusing session request for client /114.87.234.228:57699 as it has seen zxid 0x7 our last zxid is 0x0 client must try another server
2021-11-18 00:11:10,943 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57699 (no session established for client)
2021-11-18 00:11:12,684 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57568
2021-11-18 00:11:12,695 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@922] - Refusing session request for client /114.87.234.228:57568 as it has seen zxid 0x7 our last zxid is 0x0 client must try another server
2021-11-18 00:11:12,696 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57568 (no session established for client)
2021-11-18 00:11:14,703 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57601
2021-11-18 00:11:14,743 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@922] - Refusing session request for client /114.87.234.228:57601 as it has seen zxid 0x7 our last zxid is 0x0 client must try another server
2021-11-18 00:11:14,743 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57601 (no session established for client)
2021-11-18 00:11:15,412 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57800
2021-11-18 00:11:15,414 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@949] - Client attempting to establish new session at /114.87.234.228:57800
2021-11-18 00:11:15,416 [myid:] - INFO [SyncThread:0:FileTxnLog@213] - Creating new log file: log.1
2021-11-18 00:11:15,427 [myid:] - INFO [SyncThread:0:ZooKeeperServer@694] - Established session 0x100137139d30000 with negotiated timeout 5000 for client /114.87.234.228:57800
2021-11-18 00:11:16,843 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@487] - Processed session termination for sessionid: 0x100137139d30000
2021-11-18 00:11:16,845 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57800 which had sessionid 0x100137139d30000
2021-11-18 00:11:17,354 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57488
2021-11-18 00:11:17,354 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@949] - Client attempting to establish new session at /114.87.234.228:57488
2021-11-18 00:11:17,356 [myid:] - INFO [SyncThread:0:ZooKeeperServer@694] - Established session 0x100137139d30001 with negotiated timeout 5000 for client /114.87.234.228:57488
2021-11-18 00:11:18,817 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@487] - Processed session termination for sessionid: 0x100137139d30001
2021-11-18 00:11:18,819 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57488 which had sessionid 0x100137139d30001
2021-11-18 00:11:19,344 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57417
2021-11-18 00:11:19,355 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@949] - Client attempting to establish new session at /114.87.234.228:57417
2021-11-18 00:11:19,357 [myid:] - INFO [SyncThread:0:ZooKeeperServer@694] - Established session 0x100137139d30002 with negotiated timeout 5000 for client /114.87.234.228:57417
2021-11-18 00:14:25,024 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@487] - Processed session termination for sessionid: 0x100137139d30002
2021-11-18 00:14:25,026 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /114.87.234.228:57417 which had sessionid 0x100137139d30002
2021-11-18 00:14:25,730 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /114.87.234.228:57403
2021-11-18 00:14:25,731 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@949] - Client attempting to establish new session at /114.87.234.228:57403
2021-11-18 00:14:25,733 [myid:] - INFO [SyncThread:0:ZooKeeperServer@694] - Established session 0x100137139d30003 with negotiated timeout 5000 for client /114.87.234.228:57403
zookeeper客户端连接的截图
kafka的日志
[2021-11-18 00:18:27,177] INFO Client environment:java.library.path=/usr/lib/jvm/zulu8-ca/jre/lib/amd64/server:/usr/lib/jvm/zulu8-ca/jre/lib/amd64:/usr/lib/jvm/zulu8-ca/jre/…/lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,177] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:java.compiler= (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:os.version=5.10.60-9.al8.x86_64 (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:user.dir=/ (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:os.memory.free=973MB (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:os.memory.max=1024MB (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,178] INFO Client environment:os.memory.total=1024MB (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,182] INFO Initiating client connection, connectString=106.14.132.94:2181 sessionTimeout=18000 watcher=kafka.zookeeper.ZooKeeperClient Z o o K e e p e r C l i e n t W a t c h e r ZooKeeperClientWatcher ZooKeeperClientWatcher@4466af20 (org.apache.zookeeper.ZooKeeper)
[2021-11-18 00:18:27,215] INFO jute.maxbuffer value is 4194304 Bytes (org.apache.zookeeper.ClientCnxnSocket)
[2021-11-18 00:18:27,223] INFO zookeeper.request.timeout value is 0. feature enabled= (org.apache.zookeeper.ClientCnxn)
[2021-11-18 00:18:27,226] INFO [ZooKeeperClient Kafka server] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
进入容器内部发送消息
`bash-5.1# ./kafka-console-producer.sh --broker-list 106.14.132.94:9092 --topic sun
[2021-11-18 00:17:06,318] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,319] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,413] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,414] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,514] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,514] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,715] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:06,716] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:08,276] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:08,276] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:09,031] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:09,031] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:11,092] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:11,092] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:13,012] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:13,012] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:14,017] WARN [Producer clientId=console-producer] Connection to node -1 (/106.14.132.94:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2021-11-18 00:17:14,017] WARN [Producer clientId=console-producer] Bootstrap broker 106.14.132.94:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
`
又找了找,还是没什么用
用netstat查看网络连接状态
netstat -antp | grep 2181
用tcpdump抓包和wireshark分析
tcpdump -vv host 106.14.132.94 and port 2181 -w 2181.cap
tcpdump -r 2181.cap
没有发现什么有用信息,这个时候原来的sasl认证的错误信息没有了,出现了新的问题。
zookeeper还是老样子,可以连接上
后续发现将命令绑定的ip替换成内网ip就好了,因为不用内网会出现以下的这种情况
这个时候删除重来,命令如下:
docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka
firewall-cmd --add-port=8010/tcp --permanent
firewall-cmd --add-port=8011/tcp --permanent
firewall-cmd --reload
systemctl restart docker
firewall-cmd --query-port=2181/tcp
firewall-cmd --query-port=9092/tcp
docker run -dit --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 --name zookeeper \
-p 2181:2181 \
-v /etc/localtime:/etc/localtime \
-t wurstmeister/zookeeper
docker run -dit --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=172.21.17.47:2181 \
-e KAFKA_ADVERTISED_HOST_NAME=172.21.17.47 \
-e KAFKA_ADVERTISED_PORT=9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://172.21.17.47:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://172.21.17.47:9092 \
-v /etc/localtime:/etc/localtime \
-t wurstmeister/kafka
然后又出现下面的这种情况了:Opening socket connection to server 172.21.17.47/172.21.17.47:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
又回到一开始的问题了,Will not attempt to authenticate using SASL 但是发现截图好像是多了一个ip地址:
后面发现我的启动kafka的命令中配置错了,kafka的启动命令多加了二行配置
-e KAFKA_ADVERTISED_HOST_NAME=172.21.17.47 \
-e KAFKA_ADVERTISED_PORT=9092 \
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)