HBase给予" JAVA_HOME未设置"在跑步的时候

时间:2017-07-31 11:31:33

标签: java hbase

我正在使用MacOS Sierra version 10.12.4并使用zsh shell。我安装了HBase version 1.2.6并尝试运行它。我已经预先安装了JAVA JDK version 1.8.0_131

我在$JAVA_HOME~.bash_profile以及~.zshrc文件中设置了hbase-1.2.6/conf/hbase-env.sh路径。因此,当我运行以下命令时,它会显示此

 ❯ echo $JAVA_HOME                                                                                                                                                        

 /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/

❯ $JAVA_HOME/bin/java -version                                                                                                                                           [16:55:16]
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

但是,当我在文件夹hbase-1.2.6内运行以下命令时  要运行HBase,它会给我JAVA_HOME is not set error

 ❯ sudo bin/start-hbase.sh                                                                                                                                            

Password:
+======================================================================+
|                    Error: JAVA_HOME is not set                       |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site        |
|     > http://www.oracle.com/technetwork/java/javase/downloads        |
|                                                                      |
| HBase requires Java 1.7 or later.                                    |
+======================================================================+


❯ sudo bin/hbase shell                                                                                                                                                   [16:58:36]
+======================================================================+
|                    Error: JAVA_HOME is not set                       |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site        |
|     > http://www.oracle.com/technetwork/java/javase/downloads        |
|                                                                      |
| HBase requires Java 1.7 or later.                                    |
+======================================================================+                           |

我可以在用户级别运行它而不使用sudo。我怎样才能在sudo级别运行?

2 个答案:

答案 0 :(得分:0)

你应该运行

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jd‌​k/Contents/Home/ 

HBase指针内运行HBase之前。并检查JAVA_HOME是否指向Linux中的正确目录。

答案 1 :(得分:0)

Step 1: Search JAVA_HOME in  hbase-env.sh 
Step 2: Comment out # from JAVA_HOME line and edit the JAVA_HOME directory