"The node /hbase is not in ZooKeeper" 当 运行 在 Hbase 中执行命令时 shell

"The node /hbase is not in ZooKeeper" when running commands in Hbase shell

我正在尝试以独立模式安装 HBase v1.1.2(使用 Hadoop v2.7.2),并尽可能地遵循 Apache HBase docs,但是配置似乎有点棘手。不确定这是否与我使用自制软件安装 HBase 而不是通过他们的镜像站点之一直接下载有关。我的目标是达到可以执行创建表、列出现有表等操作的程度

我安装了Java 1.7.0,我运行 "brew install hbase" 安装了hbase。在 Homebrew 的 hbase 目录中,我打开了 /libexec/conf/hbase-env.sh,我在第 27 行看到以下内容:

export JAVA_HOME="$(/usr/libexec/java_home)"

当我在命令行中执行/usr/libexec/java_home时,它输出/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home。所以似乎设置了一个有效的 $JAVA_HOME env 变量。

在我的 /libexec/conf/hbase-site.xml 配置文件中,我设置了以下 key/value 对:

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/richiethomas/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/richiethomas/zookeeper</value>
  </property>
</configuration>

换句话说,我已经复制了 HBase 文档中显示的配置,只是将 'testuser' 替换为 'richiethomas',因为这是我在命令中使用的用户名线.

然后在 Homebrew hbase 目录中,我 运行 `./bin/start-hbase.sh'。我看到以下内容:

starting master, logging to /usr/local/Cellar/hbase/1.1.2/libexec/bin/../logs/hbase-richiethomas-master-MacBook-Pro-5.local.out

然后,我 运行 hbase shell 看到以下内容:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hbase/1.1.2/libexec/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/2.7.2/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2017-01-03 17:27:52,056 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.1.2, rcc2b70cf03e3378800661ec5cab11eb43fafe0fc, Wed Aug 26 20:11:27 PDT 2015

>>

执行此操作后,在新的 CLI 选项卡中,我 cat 来自我在上面看到的路径 (/usr/local/Cellar/hbase/1.1.2/libexec/bin/../logs/hbase-richiethomas-master-MacBook-Pro-5.local.out) 的日志,我看到以下内容:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hbase/1.1.2/libexec/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/2.7.2/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

然后,回到我的 HBase shell,我 运行 以下内容以查看是否一切正常,我看到以下内容:

>> list
TABLE                                                                                                                                                                            
2017-01-03 17:28:05,108 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
2017-01-03 17:28:05,320 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
2017-01-03 17:28:05,625 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
2017-01-03 17:28:06,128 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
2017-01-03 17:28:07,134 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
2017-01-03 17:28:09,144 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.
2017-01-03 17:28:13,158 ERROR [main] client.ConnectionManager$HConnectionImplementation: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.

ERROR: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the master.

Here is some help for this command:
List all tables in hbase. Optional regular expression parameter could
be used to filter the output. Examples:

  hbase> list
  hbase> list 'abc.*'
  hbase> list 'ns:abc.*'
  hbase> list 'ns:.*'

根据 Apache 文档:

You do not need to create the HBase data directory. HBase will do this for you. If you create the directory, HBase will attempt to do a migration, which is not what you want.

我将其解释为我不需要在 hbase-site.xml 中设置以下 属性,特别是因为 'hbase' 是 'zookeeper.znode.parent' 的默认值:

<property>
    <name>zookeeper.znode.parent</name>
    <value>/hbase</value>
</property>

jps 的输出如下:

32146 ZooKeeperMain
1364 QuorumPeerMain
83568 
34120 Jps

我的 zoo.cfg 文件位于 /usr/local/etc/zookeeper/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=/usr/local/var/run/zookeeper/data
# 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

我尝试过的解决方案:

我.

我尝试将 hbase-site.xml 文件中 zookeeper.property.dataDir 的值替换为 /usr/local/var/run/zookeeper/data,但这并没有解决问题。

二.

当我在命令行运行zkcli和运行ls /时,我只看到zookeeper,没有hbase目录。我在 zookeeper shell:

中尝试 运行ning 以下命令

create /hbase my_data

然后我看到以下内容:

[zk: localhost:2181(CONNECTED) 4] ls /
[hbase, zookeeper]

然后当我退出并重新运行 HBase shell,并尝试list,我看到以下内容:

>> list
TABLE                                                                                                                                                                            

ERROR: Can't get master address from ZooKeeper; znode data == null

III.

根据 this Quora article,HBase 1.1.2 仅支持 Hadoop 版本 2.5.x,所以我 运行 brew uninstall hadoop 后跟 brew install hadoop25 ,运行 停止和启动 hbase 脚本,并重新启动 hbase shell。仍然没有运气。

四.

我尝试卸载 Homebrew 版本并从 Apache 镜像站点下载 HBase,并在 hbase-site.xml 中重复配置过程,但我得到了同样的错误 (The node /hbase is not in ZooKeeper. It should have been written by the master.)。

V.

我通过 Homebrew uninstalled/reinstalled HBase,并按照 "Caveats" 部分中的说明进行操作:

==> Caveats
To have launchd start hbase now and restart at login:
  brew services start hbase
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/hbase/bin/start-hbase.sh

我注意到在 运行 执行上述命令后,hbase-site.xml 文件中填充了看起来合理的 hbase.rootdirhbase.zookeeper.property.dataDir 值(具体来说,file:///usr/local/var/hbase/usr/local/var/zookeeper)。我还注意到,当我 运行 brew services start hbase,然后 运行 jps,我没有看到 'HMaster' 进程 运行ning,但是我当我 运行 /usr/local/opt/hbase/bin/start-hbase.sh 时确实看到了 HMaster。然而,我随后尝试启动 hbase shell 并输入 status,但我得到了与之前相同的错误 (The node /hbase is not in ZooKeeper.)。

六.

我已经验证我的 Hadoop 安装是 运行ning OK:

MacBook-Pro-5:2.5.2 richiethomas$ hadoop jar /usr/local/Cellar/hadoop25/2.5.2/libexec/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.2.jar pi 2 5
Number of Maps  = 2
Samples per Map = 5
17/01/03 20:09:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Wrote input for Map #0
Wrote input for Map #1
Starting Job
...
Job Finished in 2.156 seconds
Estimated value of Pi is 3.60000000000000000000

看来我的 HBase 配置有问题,但我不确定在这里还能尝试什么。

由于您要设置独立的 hbase,因此无需构建 hdfszk

你的问题的原因是,hbase会尝试启动一个内部zk服务,但是因为已经有一个java进程QuorumPeerMain占用了端口 2181hbase 将无法启动。如果hbase启动成功,会出现一个java进程,名称为HMaster.

要验证这一点,请检查日志的最后一行 hbase-richiethomas-master-MacBook-Pro-5.local.out,您可能会看到如下错误消息:

Could not start ZK at requested port of 2181.  ZK was started at port: 2182.  Aborting as clients (e.g. shell) will not be able to find this ZK quorum.

所以,解决方案是:

  1. 杀死现有的QuorumPeerMain
  2. 运行 start-hbase.sh 再一次