zkCli localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)

无聊之余搭建zookeeper集群,我选择了3台服务器,
详见配置文件,

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zkdata
# the port at which the clients will connect
clientPort=1290
server.1=192.168.187.128:1281:1282
server.2=192.168.187.129:1291:1292
server.3=192.168.187.130:1301:1302

# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

搭建集群首要记得,设置zookpeer的数据快照目录。也就是配置文件中的dataDir
在这个数据目录中,需要创建myid文件,文件中写入id.
server.1=192.168.187.128:1281:1282, 等号前面的1就是id,也是服务器的唯一身份编号。
好了,我是在bin目录里面,通过 ./zkCli.sh 命令,连接某一个zookeeper服务,结果
在这里插入图片描述
上来就是报这个异常,最开始我以为是myid文件设置的不正确,导致配置数据没有正确读取到。
但是查看单台服务器在集群中的角色时,发现服务启动是正常的。

[root@192 bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: leader
[root@192 bin]# 

可以看到,正常显示了某台服务器在集群中的角色,证明服务启动没问题。
继续排查,服务没问题,那就是zookeeper 提供客户端工具连接的时候有问题啦。
而且还有个问题,那就是配置文件中,连接zookeeper的端口号,已经改为1290,zkCli还是尝试2181的端口连接。
肯定不对的嘛。
所以呢,连接时指定下端口号,应该可以
./zkCli.sh -server localhost:1290

[root@192 bin]# ./zkCli.sh -server localhost:1290
Connecting to localhost:1290
2022-08-12 13:35:41,464 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
2022-08-12 13:35:41,468 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=192.168.187.129
2022-08-12 13:35:41,468 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_341
2022-08-12 13:35:41,470 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2022-08-12 13:35:41,470 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_341-amd64/jre
2022-08-12 13:35:41,470 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper-3.4.12/bin/../build/classes:/usr/local/zookeeper-3.4.12/bin/../build/lib/*.jar:/usr/local/zookeeper-3.4.12/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/zookeeper-3.4.12/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/zookeeper-3.4.12/bin/../lib/netty-3.10.6.Final.jar:/usr/local/zookeeper-3.4.12/bin/../lib/log4j-1.2.17.jar:/usr/local/zookeeper-3.4.12/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.12/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/zookeeper-3.4.12/bin/../zookeeper-3.4.12.jar:/usr/local/zookeeper-3.4.12/bin/../src/java/lib/*.jar:/usr/local/zookeeper-3.4.12/bin/../conf:
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-1160.el7.x86_64
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2022-08-12 13:35:41,471 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/usr/local/zookeeper-3.4.12/bin
2022-08-12 13:35:41,472 [myid:] - INFO  [main:ZooKeeper@441] - Initiating client connection, connectString=localhost:1290 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@1a86f2f1
2022-08-12 13:35:41,507 [myid:] - INFO  [main-SendThread(localhost:1290):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:1290. Will not attempt to authenticate using SASL (unknown error)
2022-08-12 13:35:41,514 [myid:] - INFO  [main-SendThread(localhost:1290):ClientCnxn$SendThread@878] - Socket connection established to localhost/127.0.0.1:1290, initiating session
Welcome to ZooKeeper!
JLine support is enabled
2022-08-12 13:35:41,567 [myid:] - INFO  [main-SendThread(localhost:1290):ClientCnxn$SendThread@1302] - Session establishment complete on server localhost/127.0.0.1:1290, sessionid = 0x200009e1b500001, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:1290(CONNECTED) 0] 

正常进来了,所以折腾了一个多小时,就这?
zkCli连接时 默认的 localhost:2181 IP跟端口号,所以一直在尝试连接这个服务。

总结:

  1. /zkCli.sh 192.168.187.129:1290
  2. /zkCli.sh /usr/local/zookeeper/conf/zoo.cfg
    一种方式,指定IP+端口,
    一种指定配置文件路径, 通过文件里面的配置进行连接
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误消息"Opening socket connection to server :2181. Will not attempt to authenticate using SASL (unknown error)"通常与ZooKeeper连接时身份认证相关的问题有关。根据提供的引用内容,可以看出用户在连接ZooKeeper服务时遇到了这个错误。 该错误消息中的"Will not attempt to authenticate using SASL (unknown error)"表明身份验证过程出现了未知错误。可能的原因之一是在连接ZooKeeper时配置的身份验证机制不正确或存在问题。这可能导致ZooKeeper无法通过SASL进行身份认证。 另外,从引用中可以看出,用户在尝试连接ZooKeeper时使用了默认的主机IP和端口号(localhost:2181)。这可能是导致连接失败的另一个原因。请确保您正在尝试连接的ZooKeeper服务的主机IP和端口号是正确的。 为解决这个问题,您可以采取以下步骤: 1. 确保您正在连接的ZooKeeper服务的主机IP和端口号是正确的。您可以检查ZooKeeper服务的配置文件(如zoo.cfg)以获取正确的主机IP和端口号。 2. 检查身份验证机制的配置。确保在连接ZooKeeper时使用的身份验证机制是正确的,并且相应的配置也正确。您可以参考ZooKeeper的文档和配置文件来了解正确的身份验证配置。 3. 如果问题仍然存在,您可以尝试重新启动ZooKeeper服务并检查日志文件以获取更多详细信息。日志文件通常位于ZooKeeper安装目录的logs目录下。 总结:当连接ZooKeeper服务时遇到"Opening socket connection to server :2181. Will not attempt to authenticate using SASL (unknown error)"错误消息时,可能是由于身份验证机制的配置问题或连接信息(主机IP和端口号)不正确导致的。您可以通过检查配置文件和重新启动服务来解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Kafka 使用](https://download.csdn.net/download/weixin_38735987/14038995)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [zkCli localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)](https://blog.csdn.net/lantianlu3/article/details/126302174)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值