Zookeeper- Error contacting service. It is probably not running解决方案和原理

搭建启动Zookeeper集群出现Error contacting service. It is probably not running解决方案和原理

1.关闭防火墙 

[[email protected] bin]# zkServer.sh start
JMX enabled by default
Using config: /usr/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 2.检查zookeeper状态 

[[email protected] bin]# zkServer.sh status
JMX enabled by default
Using config: /usr/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.

 3.查看log日志文件

[[email protected] bin]# cat zookeeper.out

以下是相关Exception:

2017-08-04 14:39:01,523 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:[email protected]] - Notification time out: 60000
2017-08-04 14:40:01,525 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:[email protected]] - Cannot open channel to 2 at election address srv02/192.168.1.89: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:368)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:762)
2017-08-04 14:40:01,528 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:[email protected]] - Cannot open channel to 3 at election address srv03/192.168.1.90: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:368)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
	at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)
	at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:762)
2017-08-04 14:40:01,529 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:[email protected]] - Notification time out: 60000
2017-08-04 14:40:43,444 [myid:1] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]] - Accepted socket connection from /127.0.0.1:58217
2017-08-04 14:40:43,444 [myid:1] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]] - Processing srvr command from /127.0.0.1:58217
2017-08-04 14:40:43,445 [myid:1] - INFO  [Thread-3:[email protected]] - Closed socket connection for client /127.0.0.1:58217 (no session established for client)

注意颜色字体,意思是无法打开选举通道2和3,造成的原因是,zookeeper集群开启时有个选举过程,此时我仅开启一台机器,由于其他两台机器没有开启,它发出去的报文没有任何响应,导致它的选举状态一直处于LOOKING状态。

同时把另外两台机器srv02,srv03开启,3台机器组网形成集群,立即选举出leader就能清晰地看到zookeeper集群的状态了。

用命令 jps 查看进程是否开启

要清晰的处理这个问题就要从zookeeper的选举机制来了解

zookeeper的选举机制(全新集群paxos)以一个简单的例子来说明整个选举的过程.
假设有五台服务器组成的zookeeper集群,它们的id从1-5,同时它们都是最新启动的,也就是没有历史数据,在存放数据量这一点上,都是一样的.假设这些服务器依序启动,来看看会发生什么.
1) 服务器1启动,此时只有它一台服务器启动了,它发出去的报没有任何响应,所以它的选举状态一直是LOOKING状态
2) 服务器2启动,它与最开始启动的服务器1进行通信,互相交换自己的选举结果,由于两者都没有历史数据,所以id值较大的服务器2胜出,但是由于没有达到超过半数以上的服务器都同意选举它(这个例子中的半数以上是3),所以服务器1,2还是继续保持LOOKING状态.
3) 服务器3启动,根据前面的理论分析,服务器3成为服务器1,2,3中的老大,而与上面不同的是,此时有三台服务器选举了它,所以它成为了这次选举的leader.
4) 服务器4启动,根据前面的分析,理论上服务器4应该是服务器1,2,3,4中最大的,但是由于前面已经有半数以上的服务器选举了服务器3,所以它只能接收当小弟的命了.
5) 服务器5启动,同4一样,当小弟.

非全新集群的选举机制(数据恢复)

那么,初始化的时候,是按照上述的说明进行选举的,但是当zookeeper运行了一段时间之后,有机器down掉,重新选举时,选举过程就相对复杂了。

需要加入数据id、leader id和逻辑时钟。

数据id:数据新的id就大,数据每次更新都会更新id。

Leader id:就是我们配置的myid中的值,每个机器一个。

逻辑时钟:这个值从0开始递增,每次选举对应一个值,也就是说:  如果在同一次选举中,那么这个值应该是一致的 ;  逻辑时钟值越大,说明这一次选举leader的进程更新.

选举的标准就变成:

1、逻辑时钟小的选举结果被忽略,重新投票

2、统一逻辑时钟后,数据id大的胜出

3、数据id相同的情况下,leader id大的胜出

根据这个规则选出leader。

 
时间: 2024-11-18 19:43:19

Zookeeper- Error contacting service. It is probably not running解决方案和原理的相关文章

Zookeep启动异常:Error contacting service. It is probably not running.

Zookeep安装启动异常    异常提示: [[email protected] bin]# ./zkServer.sh status JMX enabled by default Using config: /usr/local/zk/bin/../conf/zoo.cfg Error contacting service. It is probably not running 解决方案: 网上问题答案有许多种,一一归纳: 1. zoo.cfg配置文件中指定目录却没有创建! 创建相应目录即可

启动zookeeper时,jps显示有进程,但是status查看状态时就Error contacting service. It is probably not running

转自:http://www.cnblogs.com/xiaohua92/p/5460515.html#undefined 安装zookeeper时候,可以查看进程启动,但是状态显示报错:Error contacting service. It is probably not running 安装zookeeper-3.3.2的时候,启动正常没报错,但zkServer.sh status查看状态的时候却出现错误,如下: JMX enabled by defaultUsing config: /ha

安装zookeeper时候,可以查看进程启动,但是状态显示报错:Error contacting service. It is probably not running

安装zookeeper-3.3.2的时候,启动正常没报错,但zkServer.sh status查看状态的时候却出现错误,如下: JMX enabled by defaultUsing config: /hadoop/zookeeper/bin/../conf/zoo.cfgError contacting service. It is probably not running. jps查看进程,却发现进程已启动 7313  QuorumPeerMain 在网上查阅资料一共有三种解决方法: 1,

zookeeper 集群 Cannot open channel to X at election address Error contacting service. It is probably not running.

zookeeper集群   启动 1.问题现象. 启动每一个都提示  STARTED 但是查看 status时全部节点都报错 [[email protected] bin]# sh zkServer.sh  start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper-3.4.8/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [[email protect

zookeeper环境搭建中的几个坑[Error contacting service. It is probably not running]的分析及解决

Zookeeper简介 关于zk的介绍, zk的paxos算法, 网上已经有各位大神在写了, 本文主要写我在搭建过程中的几个极有可能遇到的坑. Zookeeper部署中的坑 坑之一 Error contacting service. It is probably not running 在配置完zookeeper集群后,三个节点,分别启动三个节点如下: [[email protected] bin]# zkServer.sh start JMX enabled by default Using

在配置zookeeper遇到Error contacting service. It is probably not running

在配置完zookeeper集群后,三个节点,分别启动三个节点如下: [[email protected] bin]# zkServer.sh startJMX enabled by defaultUsing config: /usr/local/zk/bin/../conf/zoo.cfgStarting zookeeper ... STARTED 在查看zookeeper状态时遇到 [[email protected] bin]# zkServer.sh statusJMX enabled b

zookeeper错误Error contacting service. It is probably not running.

./zkServer.sh start启动成功,并且使用jps能看zookeeper的进程. ./zkServer.sh status缺报错,Error contacting service. It is probably not running. 好多地方说和防火墙有关系 我的解决办法是先看一下2181是否被占用,如果没有被占用查看8080端口是否会占用 zookeeper有一个内嵌的管理控制台是通过jetty启动,会占用8080端口 通过查看zookeeper的官方文档,发现有3种解决途径:

Zookeeper群起脚本启动失败及查看状态出现:Error contacting service. It is probably not running

1.问题: 群起脚本启动后查看jps没有出现:QuorumPeerMain Zookeeper正常启动但是群起脚本查状态出现:Error contacting service. It is probably not running错误 ZooKeeper JMX enabled by default Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg Error contacting service. It is prob

zz-zookeeper 启动失败 BindException: Address already in use 或者Error contacting service. It is probably not running

https://www.bbsmax.com/A/ZOJPOw8xzv/ 平台:centos-6.3-i386 jdk-7u51 storm 0.9.1 python 2.6.6   hadoop 1.2.1 今天上午装storm的时候遇到这个问题,好郁闷.把网上介绍的方法都试了一遍,都没能很好的解决问题. 先介绍我自己的方法: 当我查看/bin目录下的zookeeper.out后,发现是2181端口被占用了,按照网上的方法,改成2182或者2183,都没有解决问题.此时我想到能不能把2181给