首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Hbase中运行命令时,“节点/hbase不在ZooKeeper中”

在Hbase中运行命令时,“节点/hbase不在ZooKeeper中”
EN

Stack Overflow用户
提问于 2017-01-03 22:35:54
回答 1查看 5.5K关注 0票数 2

我正试图以独立模式安装HBase v1.1.2 (使用Hadoopv2.7.2),并尽可能密切地跟踪Apache HBase文档,但是配置似乎有点棘手。不确定这是否与我用自制软件安装HBase而不是通过他们的镜像站点直接下载的事实有关。我的目标是达到这样的程度,我可以做的事情,如创建表,列出现有表等。

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

代码语言:javascript
复制
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配置文件中,我设置了以下键/值对:

代码语言:javascript
复制
<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‘替换为’richiethoma‘,因为这是我在命令行中使用的用户名。

然后,在Homebrehbase.sh目录中,运行`.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并看到以下内容:

代码语言:javascript
复制
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选项卡I中,我看到了上面看到的路径( cat )中的日志,我看到了以下内容:

代码语言:javascript
复制
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中,运行以下命令以查看是否一切正常,并看到以下内容:

代码语言:javascript
复制
>> 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‘的默认设置:

代码语言:javascript
复制
<property>
    <name>zookeeper.znode.parent</name>
    <value>/hbase</value>
</property>

jps的输出如下:

代码语言:javascript
复制
32146 ZooKeeperMain
1364 QuorumPeerMain
83568 
34120 Jps

我的zoo.cfg文件位于/usr/local/etc/zookeeper/zoo.cfg中,如下所示:

代码语言:javascript
复制
# 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

我尝试过的解决方案:

I.

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

II.

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

create /hbase my_data

然后我看到以下情况:

代码语言:javascript
复制
[zk: localhost:2181(CONNECTED) 4] ls /
[hbase, zookeeper]

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

代码语言:javascript
复制
>> list
TABLE                                                                                                                                                                            

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

III.

根据这篇Quora文章,HBase 1.1.2只支持2.5.x版本的Hadoop,所以我运行brew uninstall hadoopbrew install hadoop25,运行停止并启动hbase脚本,并重新启动hbase。还是没有运气。

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,并遵循了“注意事项”部分中的说明:

代码语言:javascript
复制
==> 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安装是否运行正常:

代码语言:javascript
复制
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配置似乎有问题,但我不确定这里还可以尝试什么。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-04 15:04:57

由于您希望设置一个独立的hbase,因此不需要构建hdfszk

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

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

代码语言:javascript
复制
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
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41453443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档