Will not attempt to authenticate using SASL (unknown error) (org

Posted m0_67306446

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Will not attempt to authenticate using SASL (unknown error) (org相关的知识,希望对你有一定的参考价值。

由于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 \\

Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)


个人简介

我是廖志伟,一名Java开发工程师,CSDN博客专家,Java领域优质创作者,《幕后大佬》社区创始人,《南北踏尘》微信公众号创始人。多年一线研发经验,曾就职多家互联网公司,参与并主导多个百万级并发的互联网产品研发与系统架构搭建,对大型分布式,高并发及微服务架构,缓存框架有非常深入的研究,对于中间件底层,架构搭建,系统调优颇多经验。

博主:java_wxid
社区:幕后大佬


本文的大概内容:

一、业务场景:报错kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING

我通过docker命令启动kafka,进入kafka容器之后,过一二秒没做操作,就出现退出容器的情况,通过zookeeper客户端连接kafka配置的zookeeper发现可以连接的上,但是查看kafka日志却报错kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING


二、错误日志:Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)


[2021-11-16 13:39:02,215] INFO Client environment:os.memory.max=1024MB (org.apache.zookeeper.ZooKeeper)
[2021-11-16 13:39:02,215] INFO Client environment:os.memory.total=1024MB (org.apache.zookeeper.ZooKeeper)
[2021-11-16 13:39:02,219] INFO Initiating client connection, connectString=106.14.132.94:2181 sessionTimeout=18000 watcher=kafka.zookeeper.ZooKeeperClient$ZooKeeperClientWatcher$@4466af20 (org.apache.zookeeper.ZooKeeper)
[2021-11-16 13:39:02,241] INFO jute.maxbuffer value is 4194304 Bytes (org.apache.zookeeper.ClientCnxnSocket)
[2021-11-16 13:39:02,248] INFO zookeeper.request.timeout value is 0. feature enabled= (org.apache.zookeeper.ClientCnxn)
[2021-11-16 13:39:02,256] INFO [ZooKeeperClient Kafka server] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
[2021-11-16 13:39:12,261] 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 13:39:12,268] INFO Socket error occurred: 106.14.132.94/106.14.132.94:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
[2021-11-16 13:39:20,258] INFO [ZooKeeperClient Kafka server] Closing. (kafka.zookeeper.ZooKeeperClient)
[2021-11-16 13:39:23,377] 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 13:39:23,482] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
[2021-11-16 13:39:23,483] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
[2021-11-16 13:39:23,485] INFO [ZooKeeperClient Kafka server] Closed. (kafka.zookeeper.ZooKeeperClient)
[2021-11-16 13:39:23,492] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
	at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:262)
	at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:119)
	at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1881)
	at kafka.server.KafkaServer.createZkClient$1(KafkaServer.scala:441)
	at kafka.server.KafkaServer.initZkClient(KafkaServer.scala:466)
	at kafka.server.KafkaServer.startup(KafkaServer.scala:233)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44)
	at kafka.Kafka$.main(Kafka.scala:82)
	at kafka.Kafka.main(Kafka.scala)
[2021-11-16 13:39:23,496] INFO shutting down (kafka.server.KafkaServer)
[2021-11-16 13:39:23,502] INFO App info kafka.server for 0 unregistered (org.apache.kafka.common.utils.AppInfoParser)
[2021-11-16 13:39:23,503] INFO shut down completed (kafka.server.KafkaServer)
[2021-11-16 13:39:23,503] ERROR Exiting Kafka. (kafka.server.KafkaServerStartable)
[2021-11-16 13:39:23,506] INFO shutting down (kafka.server.KafkaServer)

由于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 Client environment:java.compiler=<NA> (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$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=<NA> (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$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还是老样子,可以连接上

后面我会持续更新这个bug的解决过程,直到彻底解决,也希望有大佬可以在评论区留下宝贵的经验,让我可以少走弯路。


总结

以上就是今天要讲的内容,还希望各位读者大大能够在评论区积极参与讨论,给文章提出一些宝贵的意见或者建议,合理的内容,我会采纳更新博文,重新分享给大家。

一键三连

感谢大家的支持,用心写博文分享给大家,你的支持(点赞、收藏、关注)是对我创作的最大帮助。
微信公众号:南北踏尘
主页地址:https://blog.csdn.net/java_wxid
社区地址:https://bbs.csdn.net/forums/liaozhiwei

给读者大大的话

我本身是一个很普通的程序员,放在人堆里,除了与生俱来的盛世美颜、所剩不多的发量,就剩下180的大高个了。就是我这样的一个人,默默坚持写博文也有好多年了,有句老话说的好,牛逼之前都是傻逼式的坚持。希望自己可以通过大量的作品,时间的积累,个人魅力、运气和时机,可以打造属于自己的技术影响力。


提示:以下都是资源分享,求个一键三连。

博客封面

首先我要说声抱歉,作为一个学习的平台,博客封面太诱人,这样做是不好滴,但是为了让你点进来这篇博客,看到了我用心编写的博文内容,就博文质量而已,没有任何灌水的情况,也未出现与技术不相干的内容,咱们看博客,不就是看博文内容嘛,所以个人觉得还是值得的。有不少同学惦记着我博客的封面,这里也分享出来给大家,我就求个一键三连,拜托了,这对我真的很重要。
链接:https://pan.baidu.com/s/1Res9qVUKRCAqgqwTIfdM2g
提取码:2021

面试资料

福利大放送,我就求个一键三连,拜托了,这对我真的很重要。
链接:https://pan.baidu.com/s/1FycGBqVQ1xbgSpU1MBAYNQ
提取码:2021

200套PPT模板

福利大放送,我就求个一键三连,拜托了,这对我真的很重要。
链接:https://pan.baidu.com/s/16o6dtRebtBJYfb68BYaIbw
提取码:2021

提问的智慧

福利大放送,我就求个一键三连,拜托了,这对我真的很重要。
链接:https://pan.baidu.com/s/1OWTWYNpajosALT3yIH-eMQ
提取码:2021

Java开发学习路线

名称链接
JavaSEhttps://blog.csdn.net/java_wxid/category_8600390.html
MySQL专栏https://blog.csdn.net/java_wxid/category_8600406.html
JDBC专栏https://blog.csdn.net/java_wxid/category_8600515.html
MyBatis专栏https://blog.csdn.net/java_wxid/category_8600566.html
Web专栏https://blog.csdn.net/java_wxid/category_8600518.html
Spring专栏https://blog.csdn.net/java_wxid/category_8600582.html
SpringMvc专栏https://blog.csdn.net/java_wxid/category_8600599.html
SpringBoot专栏https://blog.csdn.net/wangb_java/category_9268684.html
SpringCould专栏https://blog.csdn.net/forezp/category_9268575.html
Redis专栏https://blog.csdn.net/java_wxid/category_8623958.html
Linux专栏https://blog.csdn.net/java_wxid/category_8600719.html
Maven3专栏https://blog.csdn.net/wangb_java/category_9268285.html
Spring Security5专栏https://blog.csdn.net/wangb_java/category_9284112.html
更多专栏更多专栏,请到主页查看

以上是关于Will not attempt to authenticate using SASL (unknown error) (org的主要内容,如果未能解决你的问题,请参考以下文章

spark 写 hbase 数据库,遇到Will not attempt to authenticate using SASL (unknown error)

Will not attempt to authenticate using SASL (unknown error) (org

Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)

zookeeper 客户端连接报: Will not attempt to authenticate using SASL

Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)

为什么连接HBase报错:Will not attempt to authenticate using SASL (unknown error)?