如何解决CDH5中找不到JAVA
答案:1 悬赏:40 手机版
解决时间 2021-03-07 09:08
- 提问者网友:浮克旳回音
- 2021-03-06 15:34
如何解决CDH5中找不到JAVA
最佳答案
- 五星知识达人网友:行雁书
- 2021-03-06 17:08
在安装presudo版本的CDH5中,第一次需要格式化HDFS,执行:
$ sudo -u hdfs hdfs namenode -format
但是会出现:
[root@AY1312280620257702e0Z conf]# sudo -u hdfs hdfs namenode -format
Error: JAVA_HOME is not set and could not be found.
[root@AY1312280620257702e0Z conf]# echo $JAVA_HOME
/usr/qiuxin/software/jdk1.7.0_25
[root@AY1312280620257702e0Z conf]# echo $JAVA_HOME
/usr/qiuxin/software/jdk1.7.0_25
[root@AY1312280620257702e0Z conf]# sudo -u hdfs hdfs namenode -format
Error: JAVA_HOME is not set and could not be found.
[root@AY1312280620257702e0Z conf]# java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
[root@AY1312280620257702e0Z conf]#
[root@AY1312280620257702e0Z ~]# for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
Starting Hadoop datanode:[ OK ]
Error: JAVA_HOME is not set and could not be found.
Starting Hadoop namenode:[ OK ]
Error: JAVA_HOME is not set and could not be found.
Starting Hadoop secondarynamenode:[ OK ]
Error: JAVA_HOME is not set and could not be found.
需要进行如下配置,即可解决如上问题:
在/etc/sudores 的最后一行增加:
On systems on which
sudo
clears or restricts environment variables, you also need to add the following line to the
/etc/sudoers
file:
Defaults env_keep+=JAVA_HOME
同时需要配置:
If your JDK is located at one of the standard locations, it's detected by the script (using this component called bigtop-utils). However, if it's not, you'd have to go to /etc/default/bigtop-utils and set and export JAVA_HOME ( to /usr/qiuxin/software/jdk1.7.0_25) there. You only need to do it once and all CDH components would use that variable to figure out where JDK is.
[root@AY1312280620257702e0Z ~]# vi /etc/default/bigtop-utils
增加:export JAVA_HOME=/usr/qiuxin/software/jdk1.7.0_25
[root@AY1312280620257702e0Z ~]# source /etc/default/bigtop-utils
$ sudo -u hdfs hdfs namenode -format
但是会出现:
[root@AY1312280620257702e0Z conf]# sudo -u hdfs hdfs namenode -format
Error: JAVA_HOME is not set and could not be found.
[root@AY1312280620257702e0Z conf]# echo $JAVA_HOME
/usr/qiuxin/software/jdk1.7.0_25
[root@AY1312280620257702e0Z conf]# echo $JAVA_HOME
/usr/qiuxin/software/jdk1.7.0_25
[root@AY1312280620257702e0Z conf]# sudo -u hdfs hdfs namenode -format
Error: JAVA_HOME is not set and could not be found.
[root@AY1312280620257702e0Z conf]# java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
[root@AY1312280620257702e0Z conf]#
[root@AY1312280620257702e0Z ~]# for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
Starting Hadoop datanode:[ OK ]
Error: JAVA_HOME is not set and could not be found.
Starting Hadoop namenode:[ OK ]
Error: JAVA_HOME is not set and could not be found.
Starting Hadoop secondarynamenode:[ OK ]
Error: JAVA_HOME is not set and could not be found.
需要进行如下配置,即可解决如上问题:
在/etc/sudores 的最后一行增加:
On systems on which
sudo
clears or restricts environment variables, you also need to add the following line to the
/etc/sudoers
file:
Defaults env_keep+=JAVA_HOME
同时需要配置:
If your JDK is located at one of the standard locations, it's detected by the script (using this component called bigtop-utils). However, if it's not, you'd have to go to /etc/default/bigtop-utils and set and export JAVA_HOME ( to /usr/qiuxin/software/jdk1.7.0_25) there. You only need to do it once and all CDH components would use that variable to figure out where JDK is.
[root@AY1312280620257702e0Z ~]# vi /etc/default/bigtop-utils
增加:export JAVA_HOME=/usr/qiuxin/software/jdk1.7.0_25
[root@AY1312280620257702e0Z ~]# source /etc/default/bigtop-utils
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯