zoukankan      html  css  js  c++  java
  • zookeeper 集群 Cannot open channel to X at election address Error contacting service. It is probably not running.

    zookeeper集群   启动

     

    1.问题现象。 启动每一个都提示  STARTED 但是查看 status时全部节点都报错

    [root@ip-172-31-19-246 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
    [root@ip-172-31-29-48 bin]# sh zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.8/bin/../conf/zoo.cfg
    Error contacting service. It is probably not running.

    2.打印日志 看报错  全部节点都报这个错误

     

    tail -1000f zookeeper.out 

    2016-04-27 01:22:50,087 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: node2.vvshop.cc to address: node2.vvshop.cc/54.254.152.81
    2016-04-27 01:22:50,088 [myid:1] - WARN  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 3 at election address node3.vvshop.cc/52.221.223.222: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)
    2016-04-27 01:22:50,319 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: node3.vvshop.cc to address: node3.vvshop.cc/52.221.223.222
    2016-04-27 01:22:50,319 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 60000

     3.网上寻求解决方案

    1.http://freeman983.iteye.com/blog/2053037   log目录没有创建导致出错 并不是原因。

    2.http://blog.csdn.net/qianggezhishen/article/details/49363349  (我的配置都是对的 但是仍然报错)

    ZooKeeper安装使用时遇到各种奇怪问题的解决方法:

    1.nohup:failed to run command ‘Java’: No such file or directory
    2.Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

    a.检查myid文件数字是否跟配置的能对的上

    b.检查myid文件是否已经拷贝到dataDIr配置的路径里了

    c.检查/etc/profile和/etc/environment 是否设置了Java和Zookeeper的路径

    d.Zookeeper集群节点必须是3个以上

     

    3.还是 歪果仁给力 stackoverflow 查到解决方案:

     http://stackoverflow.com/questions/30940981/zookeeper-error-cannot-open-channel-to-x-at-election-address

     例如:

    server.1=0.0.0.0:2888:3888
    server.2=192.168.10.10:2888:3888
    server.3=192.168.2.1:2888:3888


    Step 1:

    Node 1:

    zoo.cfg

    server.1= 0.0.0.0:<port>:<port2>

    server.2= <IP>:<port>:<port2>

    .

    .

    .

    server.n= <IP>:<port>:<port2>


    Node 2 :

    server.1= <IP>:<port>:<port2>

    server.2= 0.0.0.0:<port>:<port2>

    .

    .

    .

    server.n= <IP>:<port>:<port2>

     

     如愿看到: 

    [root@ip-172-31-29-48 bin]# sh zkServer.sh  status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.8/bin/../conf/zoo.cfg
    Mode: leader
    [root@ip-172-31-23-7 bin]# sh zkServer.sh  status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.8/bin/../conf/zoo.cfg
    Mode: follower
    [root@ip-172-31-19-246 bin]# sh zkServer.sh  status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.8/bin/../conf/zoo.cfg
    Mode: follower

    如果遇到 java.net.NoRouteToHostException: No route to host

    建议关闭防火墙试试

    Java.net.NoRouteToHostException:No route to host

    上网查询的结论如下:

    没有路由连接到本机,无法到达远程主机,

    原因:防火墙干扰或中间路由器停机

    (用telnet查看该机器是否正常连接,结果如下:

    Trying 199.155.122.91...
    telnet: connect to address 199.155.122.91: No route to host
    telnet: Unable to connect to remote host: No route to host)

    解决的办法是:和防火墙规则有关,关闭防火墙就可以了

    关闭防火墙之后,结果如下:

    Trying 199.155.122.91...
    telnet: connect to address 199.155.122.91: Connection refused
    telnet: Unable to connect to remote host: Connection refused

     http://blog.csdn.net/chenyi8888/article/details/8552860

  • 相关阅读:
    java 基础笔记
    专业人士给我的JAVA学习建议
    JAVA版2048
    学习构建之法后的疑问
    角色职责及技术需求相关思考
    使用Composer安装Yii2框架+Windows下的XAMPP部署Yii2
    MiniProgram开发--云开发(1)
    Android Studio丢失Logcat问题
    SSH异常处理记录
    Android环境搭建与通过命令行方式创建Android应用
  • 原文地址:https://www.cnblogs.com/xmanblue/p/5437349.html
Copyright © 2011-2022 走看看