转载请注明出处:https://blog.csdn.net/l1028386804/article/details/93750832

问题:

今天,基于Hadoop3.2.0搭建了Hadoop集群,对NameNode和Yarn做了HA,但是在运行Hadoop自带的WordCount程序时报错了,具体报错信息为:

2019-06-26 16:08:50,513 INFO mapreduce.Job: Job job_1561536344763_0001 failed with state FAILED due to: Application application_1561536344763_0001 failed 2 times due to AM Container for appattempt_1561536344763_0001_000002 exited with  exitCode: 1
Failing this attempt.Diagnostics: [2019-06-26 16:08:48.218]Exception from container-launch.
Container id: container_1561536344763_0001_02_000001
Exit code: 1[2019-06-26 16:08:48.287]Container exited with a non-zero exit code 1. Error file: prelaunch.err.
Last 4096 bytes of prelaunch.err :
Last 4096 bytes of stderr :
log4j:WARN No appenders could be found for logger (org.apache.hadoop.mapreduce.v2.app.MRAppMaster).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.[2019-06-26 16:08:48.288]Container exited with a non-zero exit code 1. Error file: prelaunch.err.
Last 4096 bytes of prelaunch.err :
Last 4096 bytes of stderr :
log4j:WARN No appenders could be found for logger (org.apache.hadoop.mapreduce.v2.app.MRAppMaster).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.For more detailed output, check the application tracking page: http://binghe104:8088/cluster/app/application_1561536344763_0001 Then click on links to logs of each attempt.
. Failing the application.

分析与解决:

在网上搜索了半天,基本上都说的是classpath的问题,于是我也先设置下classpath,具体操作如下:

1.查看Yarn的classpath

在命令行输入如下命令查看Yarn的classpath

-bash-4.1$ yarn classpath
/usr/local/hadoop-3.2.0/etc/hadoop:/usr/local/hadoop-3.2.0/share/hadoop/common/lib/*:/usr/local/hadoop-3.2.0/share/hadoop/common/*:/usr/local/hadoop-3.2.0/share/hadoop/hdfs:/usr/local/hadoop-3.2.0/share/hadoop/hdfs/lib/*:/usr/local/hadoop-3.2.0/share/hadoop/hdfs/*:/usr/local/hadoop-3.2.0/share/hadoop/mapreduce/lib/*:/usr/local/hadoop-3.2.0/share/hadoop/mapreduce/*:/usr/local/hadoop-3.2.0/share/hadoop/yarn:/usr/local/hadoop-3.2.0/share/hadoop/yarn/lib/*:/usr/local/hadoop-3.2.0/share/hadoop/yarn/*

注:查看对应的classpath的值

如果上述输出的类环境变量为空,继续下面的步骤。

2.修改mapred-site.xml

添加:

<property> <name>mapreduce.application.classpath</name><value>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*,$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*</value>
</property>

3.yarn-site.xml

添加:

<property><name>yarn.application.classpath</name><value>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*,$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*</value>
</property>

4.修改环境变量

sudo vim /etc/profile

在文件末尾添加如下信息:

export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_YARN_HOME=$HADOOP_HOME
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native

然后是系统环境变量生效

source /etc/profile

但是到这里,并没有解决问题!没有解决问题!没有解决问题!没有解决问题!

最终解决:

静下心来好好分析下问题,从日志中可以看出:由于跑AM的container退出了,并没有为任务去RM获取资源,所以,这里怀疑是AM和RM通信有问题;一台是备RM,一台活动的RM,在YARN内部,当MR去活动的RM为任务获取资源的时候没问题,但是去备RM获取时就会出现这个问题。于是找到了解决问题的方向,接下来,就在yarn-site.xml进行相应的配置。

打开yarn-site.xml,添加如下配置:

<property><name>yarn.resourcemanager.address.rm1</name><value>binghe103:8032</value>
</property>
<property><name>yarn.resourcemanager.scheduler.address.rm1</name>  <value>binghe103:8030</value>
</property>
<property><name>yarn.resourcemanager.webapp.address.rm1</name><value>binghe103:8088</value>
</property>
<property><name>yarn.resourcemanager.resource-tracker.address.rm1</name><value>binghe103:8031</value>
</property>
<property><name>yarn.resourcemanager.admin.address.rm1</name><value>binghe103:8033</value>
</property>
<property><name>yarn.resourcemanager.ha.admin.address.rm1</name><value>binghe103:23142</value>
</property><property><name>yarn.resourcemanager.address.rm2</name><value>binghe104:8032</value>
</property>
<property><name>yarn.resourcemanager.scheduler.address.rm2</name><value>binghe104:8030</value>
</property>
<property><name>yarn.resourcemanager.webapp.address.rm2</name><value>binghe104:8088</value>
</property>
<property><name>yarn.resourcemanager.resource-tracker.address.rm2</name><value>binghe104:8031</value>
</property>
<property><name>yarn.resourcemanager.admin.address.rm2</name><value>binghe104:8033</value>
</property>
<property><name>yarn.resourcemanager.ha.admin.address.rm2</name><value>binghe104:23142</value>
</property>

具体如下图所示:

整个yarn-site.xml的所有配置如下:

<configuration><property><name>yarn.resourcemanager.ha.enabled</name><value>true</value></property><property><name>yarn.resourcemanager.cluster-id</name><value>yrc</value></property><property><name>yarn.resourcemanager.ha.rm-ids</name><value>rm1,rm2</value></property><property><name>yarn.resourcemanager.hostname.rm1</name><value>binghe103</value></property><property><name>yarn.resourcemanager.hostname.rm2</name><value>binghe104</value></property><property><name>yarn.resourcemanager.zk-address</name><value>binghe105:2181,binghe106:2181,binghe107:2181</value></property><property><name>yarn.nodemanager.aux-services</name><value>mapreduce_shuffle</value></property><property><name>yarn.resourcemanager.address.rm1</name><value>binghe103:8032</value></property><property><name>yarn.resourcemanager.scheduler.address.rm1</name>  <value>binghe103:8030</value></property><property><name>yarn.resourcemanager.webapp.address.rm1</name><value>binghe103:8088</value></property><property><name>yarn.resourcemanager.resource-tracker.address.rm1</name><value>binghe103:8031</value></property><property><name>yarn.resourcemanager.admin.address.rm1</name><value>binghe103:8033</value></property><property><name>yarn.resourcemanager.ha.admin.address.rm1</name><value>binghe103:23142</value></property><property><name>yarn.resourcemanager.address.rm2</name><value>binghe104:8032</value></property><property><name>yarn.resourcemanager.scheduler.address.rm2</name><value>binghe104:8030</value></property><property><name>yarn.resourcemanager.webapp.address.rm2</name><value>binghe104:8088</value></property><property><name>yarn.resourcemanager.resource-tracker.address.rm2</name><value>binghe104:8031</value></property><property><name>yarn.resourcemanager.admin.address.rm2</name><value>binghe104:8033</value></property><property><name>yarn.resourcemanager.ha.admin.address.rm2</name><value>binghe104:23142</value></property>
</configuration>

添加完配置之后,将yarn-site.xml上传到集群中的每台服务器上重新运行程序即可。

备注:Yarn RM的HA是部署在主机名为:binghe103和主机名为:binghe104的两台服务器上的,但是yarn-site.xml文件需要上传到集群中的每台服务器上。

Hadoop之——Hadoop3.x运行自带的WordCount报错Container exited with a non-zero exit code 1.相关推荐

  1. xcode升级运行报错 Command /usr/bin/codesign failed with exit code 1(api打包出错)

    今天xcode从6.4升级到7.2.1最新版本之后,api打包错误,如下 查找了很多文档都没能解决问题,最后直接把证书替换了,成功运行打包. 参考文章:http://blog.csdn.net/jus ...

  2. python爬虫运行正常最后报错_Python爬虫运行正常,最后却报错

    问题: Python爬虫运行正常,最后却报错 描述: 刚学Python,不明白,特来请教. 程序是爬取贴吧某个地址的图片,运行正常,图片也都下载下来了. 代码如下:import urllib.requ ...

  3. 解决Windows下运行php Composer出现SSL报错的问题

    解决Windows下运行php Composer出现SSL报错的问题 2015-01-14 20:05 在windows下运行composer却出现SSL报错: E:\www>php -f co ...

  4. 已使用管理员权限运行CMD,仍报错OSError: [WinError 5] 拒绝访问。: ‘E:\\Code\\Python\\Git\\stable-diffusion-webui\\venv\\

    已使用管理员权限运行CMD,仍报错OSError: [WinError 5] 拒绝访问.: 'E:\\Code\\Python\\Git\\stable-diffusion-webui\\venv\\ ...

  5. python unittest执行程序在pycharm可以成功运行但使用cmd会报错:E列表 test_register (unittest.loader._FailedTest)

    python unittest执行程序在pycharm可以成功运行但使用cmd会报错 如题,在pycharm中执行主程序运行成功: 用例執行.debug日志均沒問題 在cmd执行主程序报错: 最惡心的 ...

  6. 使用moveit_setup_assistant生成配置包之后,在功能包内打开终端运行roslaunch demo.launch,报错 RLException: error loading <rosp

    使用moveit_setup_assistant生成配置包之后,在功能包内打开终端运行roslaunch demo.launch,报错 RLException: error loading tag: ...

  7. 运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法

    运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法 参考文章: (1)运行pyt ...

  8. win10能运行德c语言,Win10运行不了vc6.0报错“0x0000142”怎么办?

    vc6.0是微软推出的一款C++编译器,学习C语言的伙伴都会在电脑上安装VC++6.0.最近有用户升级Win10系统后,发现Win10系统运行不了VC6.0,系统报错:0x0000142,这是怎么回事 ...

  9. 数据库关键字问题mysql 运行sql语句check关键字报错

    mysql 运行sql语句check关键字报错.出错:因为check为 mysql的保留关键字,改名即可. 遇到数据库语句问题可以参考下这个问题,之前的access数据库用的check作为表明,代码迁 ...

最新文章

  1. 让你的输入框使用Google云语音输入技术
  2. 机器学习Sklearn实战——adaboost
  3. 英特尔凌动处理器_曾押宝英特尔凌动CPU,华硕手机如今活得如何了?
  4. mysql mariadb并存_MariaDB与MySQL并存
  5. 求职OMG——大学生就业指导与技能
  6. Spring Boot中表格的请求以及表格界面的显示
  7. spring boot2.0配置log4j2 发布到生成环境 报内存溢出异常 解决方案
  8. jQuery Ajax请求成功后,为什么一直在error函数里
  9. TCP建立连接的三次握手过程
  10. 两个DIV高度自适应方法(左右两个DIV高度一样)
  11. dw虚线横线的代码_虚线代码大全
  12. 三点估算法_三点估算法公式是怎么得来的
  13. LeetCode-整形数组组合最大数
  14. 网页版微信为什么打不开连接服务器失败,电脑能上微信,但是打不开网页怎么回事?...
  15. 利用边长计算三角形面积 — 海伦公式推导过程
  16. 【es6学习】Babel 转码器详解
  17. 暑假D16 T3 密道(数位DP? 打表找规律)
  18. C不会断句?【前后置,位,移位操作符详解】 b = ++c, c++, ++a, a++
  19. Workfine5.0扩展功能——如何识别身份证信息?
  20. 【RV1126】移植kaldi实时语音识别

热门文章

  1. 苹果M2驱动的MacBook Air拆解测评 详细了解新款Air其内部
  2. 动态图嵌入研究现状,方向(综述研读)
  3. 32位应用程序操作64位Windows注册表的方法
  4. 计算机应用基础的课程讨论,关于计算机应用基础的教学讨论
  5. WINDEBUGGERS 调试
  6. 宽带和下载速度是怎么换算的,它们之间的区别
  7. [FROM WOJ]#2161 罗马游戏(bzoj1455)
  8. python实验题在哪搜题_超星Python语言应用搜题公众号
  9. S60V5的应用似乎还是少了些
  10. “银联商务全民付移动支付”接入及问题处理