我已经设置了一个Hadoop 2.3.0的2节点集群。它的工作很好,我可以成功地运行distributedshell-2.2.0.jar示例。但当我尝试运行任何mapreduce作业时,我得到错误。我已经设置MapRed.xml和其他配置运行MapReduce作业根据(http://www.alexjf.net/blog/distributed-systems/hadoop-yarn-installation-definitive-guide),但我得到以下错误:
14/03/22 20:31:17 INFO mapreduce.Job: Job job_1395502230567_0001 failed with state FAILED due to: Application application_1395502230567_0001 failed 2 times due to AM Container for appattempt_1395502230567_0001_000002 exited
with exitCode: 1 due to: Exception from container-launch: org.apache.hadoop.util.Shell$ExitCodeException:
org.apache.hadoop.util.Shell$ExitCodeException:
at org.apache.hadoop.util.Shell.runCommand(Shell.java:505)
at org.apache.hadoop.util.Shell.run(Shell.java:418)
at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:650)
at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:195)
at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:283)
at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:79)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Container exited with a non-zero exit code 1
.Failing this attempt.. Failing the application.
14/03/22 20:31:17 INFO mapreduce.Job: Counters: 0
Job ended: Sat Mar 22 20:31:17 PKT 2014
The job took 6 seconds.
如果查看stderr (job的日志),只有一行 "Could not find or load main class 614"
现在我已经谷歌它,通常这个问题出现当你有不同的JAVA版本或在yarn-site.xml
类路径没有正确设置,我的yarn-site.xml
有这个
<property>
<name>yarn.application.classpath</name>
<value>/opt/yarn/hadoop-2.3.0/etc/hadoop,/opt/yarn/hadoop-2.3.0/*,/opt/yarn/hadoop-2.3.0/lib/*,/opt/yarn/hadoop-2.3.0/*,/opt/yarn/hadoop-2.3.0/lib/*,/opt/yarn/hadoop-2.3.0/*,/opt/yarn/hadoop-2.3.0/lib/*,/opt/yarn/hadoop-2.3.0/*,/opt/yarn/hadoop-2.3.0/lib/*</value>
</property>
还有其他想法吗这里的问题是什么?
我正在运行mapreduce作业:
$HADOOP_PREFIX/bin/hadoop jar $HADOOP_PREFIX/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar randomwriter out
我在尝试手动安装Hortonworks HDP 2.1时遇到了同样的问题。我成功捕获了包含以下内容的容器启动器脚本:
#!/bin/bash
export NM_HTTP_PORT="8042"
export LOCAL_DIRS="/data/1/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001,/data/2/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001,/data/3/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001,/data/4/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001"
export JAVA_HOME="/usr/java/latest"
export NM_AUX_SERVICE_mapreduce_shuffle="AAA0+gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
export CLASSPATH="$PWD:$HADOOP_CONF_DIR:$HADOOP_COMMON_HOME/share/hadoop/common/*:$HADOOP_COMMON_HOME/share/hadoop/common/lib/*:$HADOOP_HDFS_HOME/share/hadoop/hdfs/*:$HADOOP_HDFS_HOME/share/hadoop/hdfs/lib/*:$HADOOP_YARN_HOME/share/hadoop/yarn/*:$HADOOP_YARN_HOME/share/hadoop/yarn/lib/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*:job.jar/job.jar:job.jar/classes/:job.jar/lib/*:$PWD/*"
export HADOOP_TOKEN_FILE_LOCATION="/data/2/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001/container_1406927878786_0001_01_000001/container_tokens"
export NM_HOST="test02.admin.hypertable.com"
export APPLICATION_WEB_PROXY_BASE="/proxy/application_1406927878786_0001"
export JVM_PID="$$"
export USER="doug"
export HADOOP_HDFS_HOME="/usr/lib/hadoop-hdfs"
export PWD="/data/2/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001/container_1406927878786_0001_01_000001"
export CONTAINER_ID="container_1406927878786_0001_01_000001"
export HOME="/home/"
export NM_PORT="62404"
export LOGNAME="doug"
export APP_SUBMIT_TIME_ENV="1406928095871"
export MAX_APP_ATTEMPTS="2"
export HADOOP_CONF_DIR="/etc/hadoop/conf"
export MALLOC_ARENA_MAX="4"
export LOG_DIRS="/data/1/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001,/data/2/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001,/data/3/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001,/data/4/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001"
ln -sf "/data/1/hadoop/yarn/local/usercache/doug/filecache/10/libthrift-0.9.2.jar" "libthrift-0.9.2.jar"
ln -sf "/data/4/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001/filecache/13/job.xml" "job.xml"
mkdir -p jobSubmitDir
ln -sf "/data/3/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001/filecache/12/job.split" "jobSubmitDir/job.split"
mkdir -p jobSubmitDir
ln -sf "/data/2/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001/filecache/11/job.splitmetainfo" "jobSubmitDir/job.splitmetainfo"
ln -sf "/data/1/hadoop/yarn/local/usercache/doug/appcache/application_1406927878786_0001/filecache/10/job.jar" "job.jar"
ln -sf "/data/2/hadoop/yarn/local/usercache/doug/filecache/11/hypertable-0.9.8.0-apache2.jar" "hypertable-0.9.8.0-apache2.jar"
exec /bin/bash -c "$JAVA_HOME/bin/java -Dlog4j.configuration=container-log4j.properties -Dyarn.app.container.log.dir=/data/4/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001 -Dyarn.app.container.log.filesize=0 -Dhadoop.root.logger=INFO,CLA -Xmx1024m org.apache.hadoop.mapreduce.v2.app.MRAppMaster 1>/data/4/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001/stdout 2>/data/4/hadoop/yarn/logs/application_1406927878786_0001/container_1406927878786_0001_01_000001/stderr "
设置CLASSPATH
的行是罪魁祸首。为了解决这个问题,我必须在hadoop-env.sh
中设置变量HADOOP_COMMON_HOME
、HADOOP_HDFS_HOME
、HADOOP_YARN_HOME
和HADOOP_MAPRED_HOME
,以指向/usr/lib
下的适当目录。在每个目录中,我还必须设置可以找到jar的share/hadoop/...
子目录层次结构。
我用下面的方法解决了这个问题:
因为在我的hadoop/etc/hadoop[hadoop-2.7.3配置目录]:About mapred-site.xml:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
<value>zhangjunj:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>zhangjunj:19888</value>
</property>
</configuration>
在这个文件中。"zhangjunj"一定是你主人的机器名,但我在开头写的是"hadoop"。
我修复了这个问题,这是由于不正确的路径。通过给mapred, hdfs, yarn提供完整的目录路径;Common解决问题
谢谢,托尼
请检查属性。确保所有必需的jar文件都存在。
* * yarn.application.classpath * */etc/hadoop/conf/usr/lib/hadoop/,/usr/lib/hadoop/lib/,/usr/lib/hadoop-hdfs/,/usr/lib/hadoop-hdfs/lib/,/usr/lib/hadoop-yarn/,/usr/lib/hadoop-yarn/lib/,/usr/lib/hadoop mapreduce/,/usr/lib/hadoop mapreduce/lib/
也许您可以在$HADOOP_HOME/bin下使用以下代码运行HistoryServer,
./mr-jobhistory-daemon.sh start historyserver
然后你可以从这个url控制Hadoop错误的日志,(历史日志)
http://<Resource Manager Host name adress>:8088/cluster
很可能你会得到Class Not Found Exception
我在Ambari 2.0 + HDP2.3 + HUE3.9上也遇到了这个问题我的修复经验是:1. 确保所有hadoop yarn节点上都存在spark客户端2. 在所有yarn节点(spark客户端)和hue主机上导出SPARK_HOME
权限应为6050 owner:root组hadoop
——Sr-s——1 root hadoop/usr/lib/hadoop-yarn/bin/container-executor
请先检查日志(它们将在Hadoop日志目录下的用户目录中)。
还要检查yarn, hdfs, core-site XML文件中提到的所有目录的权限。因为这个错误在大多数情况下是由错误的权限问题引起的。
检查系统中的Swap大小:free -m
如果存在Swap: 0 0 0
,请按照以下说明分配交换内存
在我的情况下,问题是由于内存不足。我按照adino在上面的评论中建议的那样,将以下内容插入yarnsite-xml:
<property> <name>yarn.nodemanager.delete.debug-delay-sec</name> <value>600</value> </property>
之后,我可以在stderr日志文件中看到错误。我不记得确切的措辞(日志文件被删除了一段时间后)。提示"out of memory error"
我编辑了我的虚拟机,添加了另一个大小为3gb的交换分区(可能太夸张了)。我和Gparted就是这么做的。
之后,我必须通过键入
来注册新的交换分区mkswap /dev/sda6 (/dev/sda6 is the partition name)
swapon /dev/sda6
我通过键入"blkid"并复制uid找到了新的交换分区的uid。
我将交换注册到文件fstab:
sudo vi /etc/fstab
我为新的交换分区添加了新的行。我从之前的交换分区复制了整行代码,只是更改了UID。
UUID=2d29cddd-e721-4a7b-95c0-7ce52734d8a3 none swap sw 0 0
在此之后,错误消失。我相信有更优雅的方法来解决这个问题,但这对我来说很有效。我对Linux还是个新手。
您需要通过将yarn.nodemanager.delete.debug-delay-sec
设置为600来延迟日志删除。
这将允许您浏览相关容器目录下/hadoop/yarn/log
中的stderr, stdout和syslog。
最有可能的是,您将在syslog中找到错误。而且,最有可能的是,它将是一个ClassNotFoundException
类tez.history.logging.service.class=org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService。
如果是这种情况,则参考以下提示:
https://issues.apache.org/jira/browse/ambari - 15041