hadoop can't installation: $HADOOP_HOME or $HADOOP_PREFIX must be set

在终端执行hive时,出现错误

Cannot find hadoop installation: $HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path

问题原因:

HADOOP_HOME 路径未找到

发现真正执行的是

/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hive/bin/hive这个脚本,定位脚本报错的位置。发现有个判断环境变量的操作,而这个变量是由一个shell命令执行后输出的

hadoop can't installation: $HADOOP_HOME or $HADOOP_PREFIX must be set_第1张图片

输入which hadoop发现找不到,进入/usr/bin发现缺少软链接

 

2.进/usr/bin/目录查看hadoop
[root@hadoopnn-01 ~]# cd /usr/bin
[root@hadoopnn-01 bin]# ll hadoop
lrwxrwxrwx 1 root root 24 Nov 17 19:25 hadoop -> /etc/alternatives/hadoop

####这个 软连接 一直在跳动,说明这个 原路径/etc/alternatives/hadoop 不存在,如下图:



3.重新配置 hadoop的软连接,是由alternatives来动态管理的
[root@hadoopnn-01 bin]# alternatives --config hadoop

There are 3 programs which provide 'hadoop'.

  Selection    Command
-----------------------------------------------
*+ 1           /opt/cloudera/parcels/CDH-5.4.8-1.cdh5.4.8.p0.4/bin/hadoop
   2           /opt/cloudera/parcels/CDH-4.7.1-1.cdh4.7.1.p0.47/bin/hadoop
   3           /opt/cloudera/parcels/CDH-5.8.2-1.cdh5.8.2.p0.3/bin/hadoop

Enter to keep the current selection[+], or type selection number: 3    #输入当前CDH集群的版本

4.验证 hadoop
[root@hadoopnn-01 bin]# which hadoop
/usr/bin/hadoop
[root@hadoopnn-01 bin]#

 

你可能感兴趣的:(异常)