1. 程式人生 > >啟動hbase出現 java.lang.NoClassDefFoundError: org/apache/zookeeper/KeeperException

啟動hbase出現 java.lang.NoClassDefFoundError: org/apache/zookeeper/KeeperException

在偽分散式下啟動hadoop後,啟動hbase。

啟動前沒對關於hbase的環境有關的變數進行配置,

啟動如下,出現異常

[email protected] ~/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: +======================================================================+

對出現的這個異常回答的很充分。

一定要在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