前几段的时候,Zookeeper的安装是成功的,也启动成功,但是今天不知道就怎么了,另外一台装突然就一直启动不起来。在‘#’后面的是注释:
# 目前所在的位置:
[scidb@localhost bin]$ pwd
/home/scidb/zookeeper/zookeeper-3.4.8/bin
# 在bin的文件下有这些文件:
[scidb@localhost bin]$ ls
README.txt zkCli.cmd zkEnv.cmd zkServer.cmd zookeeper.out
zkCleanup.sh zkCli.sh zkEnv.sh zkServer.sh
# 接下来启动 zkServer.sh
[scidb@localhost bin]$ sudo sh zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/scidb/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
# 看起来是启动成功了哦,然后我们再来看看是否真的启动成功了。
[scidb@localhost bin]$ sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/scidb/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
# 呵呵,居然没有启动起来。然后我用zkCli.sh 尝试启动客户端,结果。。
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ ./zkCli.sh
Connecting to localhost:2181
2018-06-30 18:38:54,977 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
2018-06-30 18:38:54,985 [myid:] - INFO [main:Environment@100] - Client environment:host.name=iZuf6j2g9ep36k1nmcesowZ
2018-06-30 18:38:54,985 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172
2018-06-30 18:38:54,986 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2018-06-30 18:38:54,986 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/alex/data/java/jdk8/jdk1.8.0_172/jre
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/alex/data/zoookeeper/zookeeper-3.4.12/bin/../build/classes:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../build/lib/*.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../lib/slf4j-log4j12-1.7.25.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../lib/slf4j-api-1.7.25.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../lib/netty-3.10.6.Final.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../lib/log4j-1.2.17.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../lib/jline-0.9.94.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../lib/audience-annotations-0.5.0.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../zookeeper-3.4.12.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../src/java/lib/*.jar:/alex/data/zoookeeper/zookeeper-3.4.12/bin/../conf:.:/alex/data/java/jdk8/jdk1.8.0_172/jre/lib/rt.jar:/alex/data/java/jdk8/jdk1.8.0_172/lib/dt.jar:/alex/data/java/jdk8/jdk1.8.0_172/lib/tools.jar
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-693.2.2.el7.x86_64
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2018-06-30 18:38:54,987 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/alex/data/zoookeeper/zookeeper-3.4.12/bin
2018-06-30 18:38:54,988 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5c29bfd
2018-06-30 18:38:55,012 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2018-06-30 18:38:55,123 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1165] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
[zk: localhost:2181(CONNECTING) 0] 2018-06-30 18:38:56,225 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-30 18:38:56,226 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1165] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
2018-06-30 18:38:57,327 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-30 18:38:57,327 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1165] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
2018-06-30 18:38:58,428 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-30 18:38:58,429 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1165] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
2018-06-30 18:38:59,536 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-30 18:38:59,537 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1165] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
2018-06-30 18:39:00,637 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-30 18:39:00,638 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1165] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /alex/data/zoookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ sudo netstat -anp | grep 2181
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 6136/./redis-server
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 31614/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 31593/gitlab-workho
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 31582/ruby
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1321/java
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 4440/sidekiq 5.1.3
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 31570/gitaly
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 15241/sshd
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 31608/nginx: master
tcp 0 0 0.0.0.0:6783 0.0.0.0:* LISTEN 31562/alertmanager
tcp 0 0 0.0.0.0:8800 0.0.0.0:* LISTEN 31608/nginx: master
tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN 1095/java
tcp 0 0 127.0.0.1:8801 0.0.0.0:* LISTEN 31275/unicorn worke
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 31752/redis_exporte
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 31704/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 31618/postgres_expo
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 31562/alertmanager
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1321/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 1321/java
tcp6 0 0 :::6379 :::* LISTEN 6136/./redis-server
# 乍一看配置没错啊,我想看看到底2181端口是否被占用。
[scidb@localhost bin]$ sudo netstat -anp | grep 2181
# 命令没有问题,程序是真的没有启动起来。
# 接下来我在google和百度里看了搜索了许多有关于这个错误的信息。
分别搜索了‘at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)’、
‘at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
’、‘INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)’……
看了很多在http://stackoverflow.com/ 上的回答。。。
我靠,居然都没有用啊,多数都在强调你的配置文件的问题。但是配置都已经看烂了,没有什么问题啊!!!
# 好吧,最后我快绝望的我切换成root用户,然后象征性的启动,然后查看状态。
[root@localhost bin]# sh zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/scidb/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]# sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/scidb/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: standalone
# md,你敢信。。。居然好了。。。
操作流程
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ sudo -i
[root@iZuf6j2g9ep36k1nmcesowZ ~]$ cd /alex/data/zoookeeper/zookeeper-3.4.12/bin/
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ sh zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /alex/data/zoookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /alex/data/zoookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: standalone
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 6136/./redis-server
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 31614/node_exporter
tcp 0 0 0.0.0.0:34861 0.0.0.0:* LISTEN 9306/java
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 31593/gitlab-workho
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 31582/ruby
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1321/java
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 4440/sidekiq 5.1.3
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 31570/gitaly
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 15241/sshd
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 31608/nginx: master
tcp 0 0 0.0.0.0:6783 0.0.0.0:* LISTEN 31562/alertmanager
tcp 0 0 0.0.0.0:8800 0.0.0.0:* LISTEN 31608/nginx: master
tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN 1095/java
tcp 0 0 127.0.0.1:8801 0.0.0.0:* LISTEN 31275/unicorn worke
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 31752/redis_exporte
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 31704/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 31618/postgres_expo
tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN 9306/java
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 31562/alertmanager
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1321/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 1321/java
tcp6 0 0 :::6379 :::* LISTEN 6136/./redis-server
# 然后查看端口占用
[root@iZuf6j2g9ep36k1nmcesowZ /alex/data/zoookeeper/zookeeper-3.4.12/bin]$ sudo netstat -anp | grep 2181
tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN 9306/java
tcp 0 0 172.19.16.12:2181 180.167.57.46:1568 ESTABLISHED 9306/java
事情在sudo -i的强大能力下解决了~~