启动hbase出现 java.lang.NoClassDefFoundError: org/apache/zookeeper/KeeperException

时间:2021-03-09 08:26:28

在伪分布式下启动hadoop后,启动hbase。

启动前没对关于hbase的环境有关的变量进行配置,

启动如下,出现异常

thinkpad@thinkpad-117f6f ~/hbase-0.94.4
$ bin/start-hbase.sh
localhost: +======================================================================+
localhost: |      Error: JAVA_HOME is not set and Java could not be found         |
localhost: +----------------------------------------------------------------------+
localhost: | Please download the latest Sun JDK from the Sun Java web site        |
localhost: |       > http://java.sun.com/javase/downloads/ <                      |
localhost: |                                                                      |
localhost: | HBase requires Java 1.6 or later.                                    |
localhost: | NOTE: This script will find Sun Java whether you install using the   |
localhost: |       binary or the RPM based installer.                             |
localhost: +======================================================================+
starting master, logging to /home/thinkpad/hbase-0.94.4/bin/../logs/hbase-thinkpad-master-thinkpad-117f6f.out
java.lang.NoClassDefFoundError: org/apache/zookeeper/KeeperException
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
        at java.lang.Class.getMethod0(Class.java:2694)
        at java.lang.Class.getMethod(Class.java:1622)
        at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.KeeperException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
localhost: +======================================================================+
localhost: |      Error: JAVA_HOME is not set and Java could not be found         |
localhost: +----------------------------------------------------------------------+
localhost: | Please download the latest Sun JDK from the Sun Java web site        |
localhost: |       > http://java.sun.com/javase/downloads/ <                      |
localhost: |                                                                      |
localhost: | HBase requires Java 1.6 or later.                                    |
localhost: | NOTE: This script will find Sun Java whether you install using the   |
localhost: |       binary or the RPM based installer.                             |
localhost: +======================================================================+

可以看出是JAVA_HOME没设置,在网上搜索出了关于的这个问题 见http://*.com/questions/10936924/hbase-0-92-standalone-on-windows-with-cygwin

对出现的这个异常回答的很充分。

一定要在hbase-env.sh中添加JAVA_HOME和hbase的classpath两个变量,缺一不可。

export JAVA_HOME="/usr/local/jdk1.7.0_13"
export HBASE_CLASSPATH=/home/thinkpad/hbase-0.94.4/lib/

 

说明:

   下面两个不需要在系统 如.bashrc中设置,也不需要社设置hbase的。

    #export HADOOP_HOME="/home/thinkpad/hadoop-1.0.4"
    #export PATH=$HADOOP_HOME/bin:$PATH