【问题标题】:"The node /hbase is not in ZooKeeper" when running commands in Hbase shell在 Hbase shell 中运行命令时“节点 /hbase 不在 ZooKeeper 中”
【发布时间】:2017-05-18 03:09:27
【问题描述】:

我正在尝试以独立模式安装 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 环境变量。

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

<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 文档:

您不需要创建 HBase 数据目录。 HBase 会这样做 为你。如果创建目录,HBase 将尝试执行 迁移,这不是你想要的。

我将此解释为我不需要在 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

我尝试过的解决方案:

我。

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

二。

当我在命令行中运行zkcli 并运行ls / 时,我只看到zookeeper,没有看到hbase 目录。我尝试在 zookeeper shell 中运行以下命令:

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 .还是没有运气。

IV.

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

V.

我通过 Homebrew 卸载/重新安装了 HBase,并按照“警告”部分中的说明进行操作:

==> 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”进程,但是当我运行/usr/local/opt/hbase/bin/start-hbase.sh 时确实看到了HMaster。但是,然后我尝试启动 hbase shell 并输入 status,我得到了与之前相同的错误 (The node /hbase is not in ZooKeeper.)。

六.

我已验证我的 Hadoop 安装运行正常:

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 配置似乎有问题,但我不确定这里还有什么可以尝试的。

【问题讨论】:

    标签: hadoop hbase apache-zookeeper


    【解决方案1】:

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

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

    要验证这一点,请检查日志的最后一行 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

    【讨论】:

    • 当我在 Homebrew“警告”部分(即/usr/local/opt/hbase/bin/start-hbase.sh)运行命令 #2 时,我看到 HMaster 和 QuorumPeerMain 都在运行。但是,当我尝试在 shell 中运行 hbase shell 后跟 status 时,我得到了同样的错误:The node /hbase is not in ZooKeeper
    • 我的立场是正确的,毕竟这是正确的答案。我尝试同时运行 HMaster 任务和 QuorumPeerMain 任务(它是 zookeeper 的子任务),但这不起作用。我尝试杀死 QuorumPeerMain 任务,但它是另一个进程的子进程,因此它只会重新生成。我不确定卸载 zookeeper 是否安全,所以我手动重新命名它并重新启动我的机器,然后再次运行 jps 以确认没有 QuorumPeerMain 任务。然后我重新运行start-hbase.shhbase shell,这按预期工作。谢谢!
    猜你喜欢
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    相关资源
    最近更新 更多