Hbase 无法识别我的 Java 版本

Hbase 无法识别我的 Java 版本

我正在尝试使用本教程安装 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/

请按照以下步骤操作:

  1. 下载JREOracle 网站并解压缩

  2. 打开终端窗口并输入

    sudo apt-get install mc
    
  3. 安装后类型

    sudo mc
    
  4. 从终端窗口复制下载并解压JRE到文件夹中

    /usr/lib/jvm/java-version/
    
  5. 打开文件

    /etc/bash.basrc
    
  6. 将以下几行添加到末尾

    JAVA_HOME=/usr/lib/jvm/java-version/bin
    
    export JAVA_HOME
    
    PATH=$PATH:$JAVA_HOME
    
    export PATH
    
  7. 要检查JAVA_HOME设置是否正确,请运行此命令

    echo $JAVA_HOME
    

附言更改第 412 行java-start.sh

/bin/java

java

(如果存在,也包含相同的行)

答案2

您可以使用配置脚本专门为 HBase 定义所有环境变量conf/hbase-env.sh。其中有设置参数的行JAVA_HOME。通常,此行被注释掉,但您可以取消注释并根据需要设置值。

使用这种方式您不需要更改系统上的通用配置。

相关内容