zookeeper连接失败原因
环境:CentOS 8 root用户 Java 1.8 zookeeper 3.5.8
出现现象:
[root@localhost bin]
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
grep: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg: No such file or directory
grep: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
Starting zookeeper ... STARTED
[root@localhost bin]
2021-08-22 21:32:05,250 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: Connection refused
[zk: localhost:2181(CONNECTING) 0] 2021-08-22 21:32:06,355 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-22 21:32:06,356 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
2021-08-22 21:32:07,460 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-22 21:32:07,460 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: Connection refused
2021-08-22 21:32:08,566 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-22 21:32:08,567 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: Connection refused
2021-08-22 21:32:09,670 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-22 21:32:09,670 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: Connection refused
2021-08-22 21:32:10,776 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2021-08-22 21:32:10,776 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1244] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
问题产生原因:
**zoo.cfg文件未找到**
grep: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg: No such file or directory
zookeeper 3.5.8版本没有自带zoo.cfg文件
解决方法:
进入/apache-zookeeper-3.5.8-bin/conf 目录,将zoo_simple.cfg原地复制一份命名为zoo.cfg,指令为
cp zoo_simple.cfg zoo.cfg
现在重新启动zookeeper服务,成功
[root@localhost bin]
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]
/usr/bin/java
Connecting to localhost:2181
2021-08-22 21:45:02,238 [myid:] - INFO [main:Environment@109] -环境信息...省略
2021-08-22 21:45:02,246 [myid:] - INFO [main:ZooKeeper@868] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@3b764bce
2021-08-22 21:45:02,250 [myid:] - INFO [main:X509Util@79] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2021-08-22 21:45:02,257 [myid:] - INFO [main:ClientCnxnSocket@237] - jute.maxbuffer value is 4194304 Bytes
2021-08-22 21:45:02,264 [myid:] - INFO [main:ClientCnxn@1653] - zookeeper.request.timeout value is 0. feature enabled=
Welcome to ZooKeeper!
2021-08-22 21:45:02,281 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2021-08-22 21:45:02,770 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@959] - Socket connection established, initiating session, client: /0:0:0:0:0:0:0:1:40630, server: localhost/0:0:0:0:0:0:0:1:2181
2021-08-22 21:45:02,793 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1394] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x100001675940000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
启动成功
|