CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found.

安装spark过程
CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found._第1张图片
CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found._第2张图片
CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found._第3张图片
CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found._第4张图片
报错:

Error: JAVA_HOME is not set and could not be found.

排查java是否装好:

[root@node02 module]# java -version
java version "1.8.0_91"

[root@node02 module]# export
declare -x CLASSPATH=".:/*/*/jdk1.8.0_91/lib/dt.jar:/*/*/jdk1.8.0_91/lib/tools.jar"
declare -x JAVA_HOME="/opt/module/jdk1.8.0_231"

其实是Bigtop 的原因: 由于CDH不会使用系统默认JAVA_HOME环境变量,而是使用Bigtop进行管理,故我们需要安装Bigtop的规则在指定的位置安装jdk。
这里, 很明显可以看到, JAVA_HOME 并没有设置成功。可是呢? 我确实是设置了JAVA_HOME 的,而且在linux shell 执行 echo $JAVA_HOME 也是有输出的。 百思不得其解。

配置在这里:cloudera-config.sh

[root@node02 module]# find / -name cloudera-config.sh
find: ‘/proc/102639’: No such file or directory
/opt/cm-5.14.2/lib64/cmf/service/common/cloudera-config.sh
[root@node02 module]# vi /opt/cm-5.14.2/lib64/cmf/service/common/cloudera-config.sh
#!/bin/bash

# Copyright (c) 2012 Cloudera, Inc. All rights reserved.

# defines a set of helper functions that can be used by Cloudera
# manager service scripts and exports some common environment
# variables.
#

# Attempts to locate java home, prints an error and exits if no
# java can be found.
locate_java_home() {
  locate_java_home_no_verify
  verify_java_home
}

# Attempts to locate java home, but doesn't exit if none is found.
locate_java_home_no_verify() {
  local JAVA6_HOME_CANDIDATES=(
    '/usr/lib/j2sdk1.6-sun'
    '/usr/lib/jvm/java-6-sun'
    '/usr/lib/jvm/java-1.6.0-sun-1.6.0'
    '/usr/lib/jvm/j2sdk1.6-oracle'
    '/usr/lib/jvm/j2sdk1.6-oracle/jre'
    '/usr/java/jdk1.6'
    '/usr/java/jre1.6'
  )

  local OPENJAVA6_HOME_CANDIDATES=(
    '/usr/lib/jvm/java-1.6.0-openjdk'
    '/usr/lib/jvm/jre-1.6.0-openjdk'
  )

  local JAVA7_HOME_CANDIDATES=(
    '/usr/java/jdk1.7'
    '/usr/java/jre1.7'
    '/usr/lib/jvm/j2sdk1.7-oracle'
    '/usr/lib/jvm/j2sdk1.7-oracle/jre'
    '/usr/lib/jvm/java-7-oracle'
  )

  local OPENJAVA7_HOME_CANDIDATES=(
    '/usr/lib/jvm/java-1.7.0-openjdk'
    '/usr/lib/jvm/java-7-openjdk'
  )

  local JAVA8_HOME_CANDIDATES=(
    '/usr/java/jdk1.8'
    '/usr/java/jre1.8'
    '/usr/lib/jvm/j2sdk1.8-oracle'
    '/usr/lib/jvm/j2sdk1.8-oracle/jre'
    '/usr/lib/jvm/java-8-oracle'
  )

于是,建立一个已经有的JAVA_HOME 链接到 /usr/java/jdk1.8 就好了
目标位置:/usr/java/jdk1.8
原文件:/opt/module/jdk1.8.0_231
ln -s 源文件 目标文件

所有节点执行:

[root@node02 module]# mkdir /usr/java
[root@node02 module]# ln -s /opt/module/jdk1.8.0_231 /usr/java/jdk1.8

再次执行,成功安装。
CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found._第5张图片
CDH5.14安装Spark报错:Error: JAVA_HOME is not set and could not be found._第6张图片

你可能感兴趣的:(环境搭建)