Zookeeper启动查看状态时报错Error contacting service. It is probably not running.

**之前格式化了我的Hadoop文件系统。在关闭集群后,我又重启zookeeper集群,发现启动时显示正常,但是在查看状态时,显示异常,网上查阅资料都不可行。

**

[centos@r201 /home/centos]$zkServer.sh start 
ZooKeeper JMX enabled by default
Using config: /soft/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[centos@r201 /home/centos]$zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /soft/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.

下面给出我的解决方法:

在配置的dataDir目录下我的myid损失掉了,重新再输入数字1,2,3,再启动即可显示正常

        dataDir=/home/centos/zookeeper
        //server.n=host:port1:port2,数字n必须是myid中的值
        //port1:leader端口,作为leader时,供follower连接的端口
        //port2:选举端口,选举leader时供其他follower连接的端口
        server.1=r201:2888:3888
        server.2=r202:2888:3888
        server.3=r203:2888:3888

    4.在每台主机的/home/centos/zookeeper中添加myid,内容分别是1,2,3
        [r201]
        $>echo 1 > /home/centos/zookeeper/myid
        [r202]
        $>echo 2 > /home/centos/zookeeper/myid
        [r203]
        $>echo 3 > /home/centos/zookeeper/myid

你可能感兴趣的:(工具使用)