hadoop学习(一)yarn jobs pending 和 jobs map % reduce 0%

在学习Hadoop MapReduce时遇到了YARN作业pending状态和job进度停滞的问题。原因可能涉及YARN资源配置不足,如nodemanager和scheduler的内存设置。此外,解决hosts文件中的无效节点也可能有所帮助。在解决running状态下map/reduce进度为0%的问题时,发现可能是由于内存分配过少导致。修正mapred.site.xml中的mapred.job.tracker配置(应基于hdfs://而非https://)是关键。尽管仍有挑战,但已取得一些进展。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

yarn运行mapreduce程序wordcount

yarn jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jar wordcount /input/text1 /output/text2_out

坑一:
yarn jobs 一直是 pending状态 而不是 running 状态
是因为yarn-site.xml中对yarn.nodemanager.resource.memory-mb,yarn.scheduler.maximum-allocation-mb大小设置出现了 问题,经过踩坑得出结论: 至少2048+ ,否则真的会卡的动不了…

搜索回答的时候看到有人讲是Hosts的问题 修改/etc/hosts文件 删掉无关节点 虽然我不是这个问题但还是记录一下吧~
下面是我的配置:

 <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>master</value>
   </property>

   <property>
        <description>The address of the applications manager interface in the RM.</description>
        <name>yarn.resourcemanager.address</name>
        <value>${yarn.resourcemanager.hostname}:8032</value>
   </property>
   <property>
        <description>The address of the scheduler interface.</description>
        <name>yarn.resourcemanager.scheduler.address</name>
        <value>${yarn.resourcemanager.hostname}:8030</value>
   </property>
<property>
        <description>The http address of the RM web application.</description>
        <name>yarn.resourcemanager.webapp.address</name>
        <value>${yarn.resourcemanager.hostname}:8088</value>
   </property>
   <property>
        <description>The https adddress of the RM web application.</description>
        <name>yarn.resourcemanager.webapp.https.address</name>
        <value>${yarn.resourcemanager.hostname}:8090</value>
   </property>
<property>
        <name>yarn.resourcemanager.resource-tracker.address</name>
        <value>${yarn.resourcemanager.hostname}:8031</value>
   </property>
   <property>
        <description>The address of the RM admin interface.</description>
        <name>yarn.resourcemanager.admin.address</name>
        <value>${yarn.resourcemanager.hostname}:8033</value>
   </property>
   <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
   </property>
   <property>
        <name>yarn.log-aggregation.retain-seconds</name>
        <value>604800</value>
   </property>
   <property>
        <name>yarn.nodemanager.resource.memory-mb</name>
        <value>2048</value>
   </property>
   <property>
        <name>yarn.scheduler.maximum-allocation-mb</name>
        <value>2048</value>
   </property>

坑二:
jobs 是running状态的情况下 但是map reduce job的进度一直是0%
搜了好久,试了好多方法也想了想得出的结论如下:

  1. 可能是内存分配太少的问题,我的total memory显示只有4GB,4GB的电脑我已经尽力了…
    似乎正常都是二十几GB左右的样子,按理说我的主节点设置了2GB,子节点为1GB,可能虚拟内存的时候只计算了主节点乘节点数嘛… 大神求解,嘤嘤嘤~~~
  2. 我最后是因为mapreduce的配置出现了问题,修改了maprd.site.xml配置,之前配置也太粗心了,mapred.job.tracker属性的value应该是基于hdfs:// 而不是https://… 对原理还是理解不清晰,课程讲的太快了老师也不讲清楚 就要考试了还是一知半解 绝望了…
<configuration>
      <property>  
        <name>mapreduce.framework.name</name>  
        <value>yarn</value>  
      </property>
      <property>
        <name>mapred.job.tracker</name>
        <value>hdfs://192.168.11.5:9001</value>
      </property>
      <property>
      <name>mapred.local.dir</name>
       <value>/root/hadoop/var</value>
      </property>
      <property>
	<name>mapreduced.jobhistory.webapp.address</name>
	<value>master:19888</value>
      </property>
</configuration>

啊啊啊啊虽然编译器那块还是个坑,但是也算迈出一小步了,
明天还要加油鸭!!!
老大的新剧就要上了 5.7 破冰行动 耶斯!

[root@hjh01 ~]# yarn node -list 2025-07-02 19:05:04,602 INFO client.DefaultNoHARMFailoverProxyProvider: Connecting to ResourceManager at hjh01/192.168.63.101:8032 Total Nodes:3 Node-Id Node-State Node-Http-Address Number-of-Running-Containers hjh03:41086 RUNNING hjh03:8042 0 hjh02:33452 RUNNING hjh02:8042 0 hjh01:34457 RUNNING hjh01:8042 0 [root@hjh01 ~]# yarn top 2025-07-02 19:05:23,316 INFO client.DefaultNoHARMFailoverProxyProvider: Connecting to ResourceManager at hjh01/192.168.63.101:8032 YARN top - 19:06:19, up 0d, 0:26, 0 active users, queue(s): root NodeManager(s): 3 total, 3 active, 0 unhealthy, 0 decommissioned, 0 lost, 0 reb Queue(s) Applications: 0 running, 2 submitted, 0 pending, 0 completed, 0 killed Queue(s) Mem(GB): 24 available, 0 allocated, 0 pending, 0 reserved Queue(s) VCores: 24 available, 0 allocated, 0 pending, 0 reserved Queue(s) Containers: 0 allocated, 0 pending, 0 reserved q APPLICATIONID USER TYPE QUEUE PRIOR #CONT [root@hjh01 ~]# vim /usr/local/hadoop/etc/hadoop/yarn-site.xml [root@hjh01 ~]# hive which: no hbase in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/jdk/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/hive/bin:/root/bin) SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Hive Session ID = e131a6d9-ab5a-4b4c-92ef-b2ef2c57e699 Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-3.1.3.jar!/hive-log4j2.properties Async: true Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. Hive Session ID = f58a189b-6fa4-4d22-9937-2b2ffd8bf3f6 hive> SET mapreduce.map.memory.mb=2048; hive> SET mapreduce.reduce.memory.mb=4096; hive> SELECT COUNT(1) FROM hjh_table LIMIT 1; FAILED: SemanticException [Error 10001]: Line 1:21 Table not found 'hjh_table' hive> SELECT > city, > COUNT(*) AS user_count, > ROUND(AVG(age), 1) AS avg_age > FROM users > GROUP BY city > ORDER BY user_count DESC; Query ID = root_20250702192000_765e8e26-cd76-45c6-b01a-5817bcfe7ff9 Total jobs = 2 Launching Job 1 out of 2 Number of reduce tasks not specified. Estimated from input data size: 1 In order to change the average load for a reducer (in bytes): set hive.exec.reducers.bytes.per.reducer=<number> In order to limit the maximum number of reducers: set hive.exec.reducers.max=<number> In order to set a constant number of reducers: set mapreduce.job.reduces=<number> Starting Job = job_1751506776899_0003, Tracking URL = http://hjh01:8088/proxy/application_1751506776899_0003/ Kill Command = /usr/local/hadoop/bin/mapred job -kill job_1751506776899_0003 Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0 2025-07-02 19:20:53,194 Stage-1 map = 0%, reduce = 0% Ended Job = job_1751506776899_0003 with errors Error during job, obtaining debugging information... FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask MapReduce Jobs Launched: Stage-Stage-1: HDFS Read: 0 HDFS Write: 0 FAIL Total MapReduce CPU Time Spent: 0 msec hive>
最新发布
07-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值