在zookeeper配置好,并使用脚本启动zookeeper之后,查看zookeeper的进程时候,出现
[hadoop@hadoop1 ~]$ runRemoteCmd.sh '/home/hadoop/app/zookeeper/bin/zkServer.sh status' all
*******************hadoop1***********************
JMX enabled by default
Using config: /home/hadoop/app/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
*******************hadoop2***********************
JMX enabled by default
Using config: /home/hadoop/app/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
*******************hadoop3***********************
JMX enabled by default
Using config: /home/hadoop/app/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
这种情况是因为在使用完zookeeper之后,没有关闭好zookeeper,导致zookeeper的唯一标识id发生了改变,我们查看在zookeeper/conf/zoo.cfg里面的文件,可以发现我们刚开始绑定的时候
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888 这里的唯一标识id对应这hadoop的虚拟机
[hadoop@hadoop1 conf]$ cat zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/home/hadoop/data/zookeeper/zkdata
dataLogDir=/home/hadoop/data/zookeeper/zkdatalog
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888
解决办法:
进入到 /home/hadoop/data/zookeeper/zkdata里面,你会发现myid里面的内容发生了改变
最开始设置的是hadoop1的myid为1,但是现在里面的数字为0或者其他数字。
这个时候就需要将每个虚拟机的唯一标识更正过来既可