我正在尝试使用本教程安装 Hbase,但遇到了一些奇怪的事情:hbase 无法识别我的 java 版本,而 Ubuntu 16.04 可以识别。
mike@mike-thinks:~/hbase-1.2.6$ ./bin/start-hbase.sh
localhost: +======================================================================+
localhost: | Error: JAVA_HOME is not set |
localhost: +----------------------------------------------------------------------+
localhost: | Please download the latest Sun JDK from the Sun Java web site |
localhost: | > http://www.oracle.com/technetwork/java/javase/downloads |
localhost: | |
localhost: | HBase requires Java 1.7 or later. |
localhost: +======================================================================+
starting master, logging to /home/mike/hbase-1.2.6/bin/../logs/hbase-mike-master-mike-thinks.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
regionserver running as process 13688. Stop it first.
mike@mike-thinks:~/hbase-1.2.6$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
我经常需要执行以下命令:export JAVA_HOME=/usr/
也许我应该编辑start-hbase.sh
它以添加 java 路径,我不记得命令了,但我找不到应该把它放在哪里。
我尝试手动设置JAVA_HOME
变量,但即使错误消息已经改变,它似乎仍然找不到它
mike@mike-thinks:~/hbase-1.2.6/bin$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/bin/
mike@mike-thinks:~/hbase-1.2.6/bin$ ./start-hbase.sh
/home/mike/hbase-1.2.6/bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
/home/mike/hbase-1.2.6/bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
starting master, logging to /home/mike/hbase-1.2.6/bin/../logs/hbase-mike-master-mike-thinks.out
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
regionserver running as process 13688. Stop it first.
mike@mike-thinks:~/hbase-1.2.6/bin$ sudo kill 13688
[sudo] password for mike:
mike@mike-thinks:~/hbase-1.2.6/bin$ ./start-hbase.sh
/home/mike/hbase-1.2.6/bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
/home/mike/hbase-1.2.6/bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
starting master, logging to /home/mike/hbase-1.2.6/bin/../logs/hbase-mike-master-mike-thinks.out
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
starting regionserver, logging to /home/mike/hbase-1.2.6/bin/../logs/hbase-mike-1-regionserver-mike-thinks.out
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/bin//bin/java: No such file or directory
更新后我现在遇到以下问题:
mike@mike-thinks:~/hbase-1.2.6/bin$ ./start-hbase.sh
/home/mike/hbase-1.2.6/bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: Not a directory
/home/mike/hbase-1.2.6/bin/hbase: line 412: exec: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: cannot execute: Not a directory
/home/mike/hbase-1.2.6/bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: Not a directory
/home/mike/hbase-1.2.6/bin/hbase: line 412: exec: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: cannot execute: Not a directory
starting master, logging to /home/mike/hbase-1.2.6/bin/../logs/hbase-mike-master-mike-thinks.out
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: Not a directory
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: exec: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: cannot execute: Not a directory
starting regionserver, logging to /home/mike/hbase-1.2.6/bin/../logs/hbase-mike-1-regionserver-mike-thinks.out
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: Not a directory
/home/mike/hbase-1.2.6/bin/../bin/hbase: line 412: exec: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java: cannot execute: Not a directory
答案1
这不是JAVA_HOME
JAVA_HOME=/usr/
这是
JAVA_HOME=/usr/lib/jvm/java-version/bin/
请按照以下步骤操作:
下载
JRE
自Oracle 网站并解压缩打开终端窗口并输入
sudo apt-get install mc
安装后类型
sudo mc
从终端窗口复制下载并解压
JRE
到文件夹中/usr/lib/jvm/java-version/
打开文件
/etc/bash.basrc
将以下几行添加到末尾
JAVA_HOME=/usr/lib/jvm/java-version/bin export JAVA_HOME PATH=$PATH:$JAVA_HOME export PATH
要检查
JAVA_HOME
设置是否正确,请运行此命令echo $JAVA_HOME
附言更改第 412 行java-start.sh
/bin/java
到
java
(如果存在,也包含相同的行)
答案2
您可以使用配置脚本专门为 HBase 定义所有环境变量conf/hbase-env.sh
。其中有设置参数的行JAVA_HOME
。通常,此行被注释掉,但您可以取消注释并根据需要设置值。
使用这种方式您不需要更改系统上的通用配置。