1.zookeeper启动正常,显示状态时提示Error contacting service. It is probably not running.
1.1打开zookeeper的debug模式:./zkServer.sh start-foreground
若显示如下:说明在zoo.cfg的clientPort=2181端口被占用,
1.2执行netstat -lntup
查看端口(lsof -i:端口号查看进程id),如果有,如下图,执行kill -9 4062(后面的进程id)/或者在zoo.cfg中更改clientPort
1.3重新启动zookeeper,执行./zkServer.sh start-foreground
,如果没有错误,那么恭喜,我的下面还有错误(泪崩)
Cannot open channel to 2 at election address /192.168.85.6:3888
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
这是在zoo.cfg中的配置:
server.1=192.168.85.5:2888:3888
server.2=192.168.85.6:2888:3888
但是两台虚拟机的ip地址如下
192.168.0.14
192.168.0.8
根据myid修改即可,例如在id=1的虚拟机上的ip是192.168.0.14,id=2的虚拟机上的ip为192.168.0.8,则修改如下
server.1=192.168.0.14:2888:3888
server.2=192.168.0.8:2888:3888
至此,依次执行
./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: follower
目前任务只到此处,新晋小白,以后持续更新