Hadoop启动错误: log4j.properties is not found...core-site.xml not found的解决办法

描述:在禁用CDH集群的Kerberos认证后,进行服务功能验证,查看HDFS文件系统时出现core-site.xml找不到错误

[root@utility ~]# hadoop fs -ls /
WARNING: log4j.properties is not found. HADOOP_CONF_DIR may be incomplete.
Exception in thread "main" java.lang.RuntimeException: core-site.xml not found
        at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2867)
        at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2815)
        at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2692)
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1329)
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1301)
        at org.apache.hadoop.conf.Configuration.setBoolean(Configuration.java:1642)
        at org.apache.hadoop.util.GenericOptionsParser.processGeneralOptions(GenericOptionsParser.java:339)
        at org.apache.hadoop.util.GenericOptionsParser.parseGeneralOptions(GenericOptionsParser.java:569)
        at org.apache.hadoop.util.GenericOptionsParser.(GenericOptionsParser.java:174)
        at org.apache.hadoop.util.GenericOptionsParser.(GenericOptionsParser.java:156)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:90)
        at org.apache.hadoop.fs.FsShell.main(FsShell.java:389)

Hadoop启动错误: log4j.properties is not found...core-site.xml not found的解决办法_第1张图片

按照提示说core-site.xml找不到, 很疑惑;明明core-site.xml等配置文件存在,且配置没有任何问题。好在经过查阅资料找到了解决办法:原来是环境变量的问题,需要配置HADOOP_CONF_DIR路径。HADOOP_CONF_DIR 变量为自己的Hadoop目录(默认是个错误的路径所以会跳错)

vi /etc/profile

export HADOOP_HOME=/opt/cloudera/parcels/CDH/lib/hadoop
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$PATH:$HADOOP_HOME/bin

保存退出使环境变量立即生效。

source /etc/profile

 再次运行命令,恢复正常。

如果修改之后仍报错,可以查看是否将HADOOP_CONF_DIR的路径配置在hadoop-env.sh中,若没有,添加保存即可解决。

Hadoop启动错误: log4j.properties is not found...core-site.xml not found的解决办法_第2张图片 

注:出现此错误主要需要检查了etc/hadoop目录下的hadoop-env.sh,mapred-env.sh与yarn-env.sh下配置的HADOOP_CONF_DIR路径。

你可能感兴趣的:(CDHErratum,core-site.xml,not,found)