解决CentOS Warning: $HADOOP_HOME is deprecated

分类:CentOS运维 阅读:91393 次

启动Hadoop时报了一个警告信息,我安装的Hadoop版本是hadoop1.0.4,具体警告信息如下:

  1. [root@localhosthadoop-1.0.4]#./bin/start-all.sh
  2. Warning:$HADOOP_HOMEisdeprecated.
网上的说法是因为Hadoop本身对HADOOP_HOME做了判断,具体在bin/hadoop和bin/hadoop-config.sh里。在hadoop-config.sh里有如下的配置:
  1. if["$HADOOP_HOME_WARN_SUPPRESS"=""]&&["$HADOOP_HOME"!=""];then
  2. echo"Warning:\$HADOOP_HOMEisdeprecated."1>&2
  3. echo1>&2
  4. fi
对于这个警告问题,解决方法如下:

1.注释掉hadoop-config.sh里的上面给出的这段if fi配置(不推荐)

2.在/etc/profile里增加一个环境变量:

export HADOOP_HOME_WARN_SUPPRESS=1

注:修改完profile后需要执行source操作使其生效

  1. source/etc/profile
备注:在ubuntu下应该是修改/home/.bashrc文件,增加一行 export HADOOP_HOME_WARN_SUPPRESS=1

执行完后我们可以检验一下配置是否成功,重新执行start-all.sh脚本:

  1. [root@localhosthadoop-1.0.4]#./bin/start-all.sh
  2. startingnamenode,loggingto/root/hadoop-1.0.4/libexec/../logs/hadoop-root-namenode-localhost.out
  3. localhost:startingdatanode,loggingto/root/hadoop-1.0.4/libexec/../logs/hadoop-root-datanode-localhost.out
  4. localhost:startingsecondarynamenode,loggingto/root/hadoop-1.0.4/libexec/../logs/hadoop-root-secondarynamenode-localhost.out
  5. startingjobtracker,loggingto/root/hadoop-1.0.4/libexec/../logs/hadoop-root-jobtracker-localhost.out
  6. localhost:startingtasktracker,loggingto/root/hadoop-1.0.4/libexec/../logs/hadoop-root-tasktracker-localhost.out
没有出现Warning: $HADOOP_HOME is deprecated,说明问题已经解决。