更新时间:2024-06-05 GMT+08:00
分享

在本地Windows环境中调测MapReduce应用

操作场景

在程序代码完成开发后,您可以在Windows环境中运行应用。本地和集群业务平面网络互通时,您可以直接在本地进行调测。

MapReduce应用程序运行完成后,可通过如下方式查看应用程序的运行情况。

  • 在IntelliJ IDEA中查看应用程序运行情况。
  • 通过MapReduce日志获取应用程序运行情况。
  • 登录MapReduce WebUI查看应用程序运行情况。
  • 登录Yarn WebUI查看应用程序运行情况。

在MapReduce任务运行过程中禁止重启HDFS服务,否则可能会导致任务失败。

运行统计样例程序

  1. 确保样例工程依赖的所有jar包已正常获取。
  2. 在IntelliJ IDEA开发环境中,打开样例工程中“LocalRunner.java”工程,右键工程,选择Run LocalRunner.main()运行应用工程。

运行多组件样例程序

  1. 将hive-site.xml、hbase-site.xml、hiveclient.properties放入工程的conf目录。
  2. 确保样例工程依赖的所有Hive、HBase相关jar包已正常获取。
  3. 打开MultiComponentLocalRunner.java,确认代码中System.setProperty("HADOOP_USER_NAME", "root");设置了用户为root,请确保场景说明中上传的数据的用户为root,或者在代码中将root修改为上传数据的用户名。
  4. 在IntelliJ IDEA开发环境中,选中“MultiComponentLocalRunner.java”工程,单击运行对应的应用程序工程。或者右键工程,选择Run MultiComponentLocalRunner.main()运行应用工程。

查看调测结果

  • 查看运行结果获取应用运行情况

    如下所示,通过控制台输出结果查看应用运行情况。

    3614 [main] INFO  org.apache.hadoop.hdfs.PeerCache  - SocketCache disabled.
    10159 [main] INFO  org.apache.hadoop.mapreduce.lib.input.FileInputFormat  - Total input files to process : 2
    11378 [main] INFO  org.apache.hadoop.mapreduce.JobSubmitter  - number of splits:2
    12707 [main] INFO  org.apache.hadoop.mapreduce.JobSubmitter  - Submitting tokens for job: job_1468241424339_0002
    16434 [main] INFO  org.apache.hadoop.yarn.client.api.impl.YarnClientImpl  - Submitted application application_1468241424339_0002
    16656 [main] INFO  org.apache.hadoop.mapreduce.Job  - The url to track the job: http://10-120-180-170:8088/proxy/application_1468241424339_0002/
    16657 [main] INFO  org.apache.hadoop.mapreduce.Job  - Running job: job_1468241424339_0002
    31177 [main] INFO  org.apache.hadoop.mapreduce.Job  - Job job_1468241424339_0002 running in uber mode : false
    31200 [main] INFO  org.apache.hadoop.mapreduce.Job  -  map 0% reduce 0%
    45893 [main] INFO  org.apache.hadoop.mapreduce.Job  -  map 100% reduce 0%
    57172 [main] INFO  org.apache.hadoop.mapreduce.Job  -  map 100% reduce 100%
    58554 [main] INFO  org.apache.hadoop.mapreduce.Job  - Job job_1468241424339_0002 completed successfully
    58908 [main] INFO  org.apache.hadoop.mapreduce.Job  - Counters: 49
    File System Counters
    FILE: Number of bytes read=75
    FILE: Number of bytes written=436979
    FILE: Number of read operations=0
    FILE: Number of large read operations=0
    FILE: Number of write operations=0
    HDFS: Number of bytes read=674
    HDFS: Number of bytes written=23
    HDFS: Number of read operations=9
    HDFS: Number of large read operations=0
    HDFS: Number of write operations=2
    Job Counters 
    Launched map tasks=2
    Launched reduce tasks=1
    Data-local map tasks=2
    Total time spent by all maps in occupied slots (ms)=206088
    Total time spent by all reduces in occupied slots (ms)=73824
    Total time spent by all map tasks (ms)=25761
    Total time spent by all reduce tasks (ms)=9228
    Total vcore-seconds taken by all map tasks=25761
    Total vcore-seconds taken by all reduce tasks=9228
    Total megabyte-seconds taken by all map tasks=105517056
    Total megabyte-seconds taken by all reduce tasks=37797888
    Map-Reduce Framework
    Map input records=26
    Map output records=16
    Map output bytes=186
    Map output materialized bytes=114
    Input split bytes=230
    Combine input records=16
    Combine output records=6
    Reduce input groups=3
    Reduce shuffle bytes=114
    Reduce input records=6
    Reduce output records=2
    Spilled Records=12
    Shuffled Maps =2
    Failed Shuffles=0
    Merged Map outputs=2
    GC time elapsed (ms)=356
    CPU time spent (ms)=2860
    Physical memory (bytes) snapshot=1601576960
    Virtual memory (bytes) snapshot=12999819264
    Total committed heap usage (bytes)=2403336192
    Shuffle Errors
    BAD_ID=0
    CONNECTION=0
    IO_ERROR=0
    WRONG_LENGTH=0
    WRONG_MAP=0
    WRONG_REDUCE=0
    File Input Format Counters 
    Bytes Read=444
    File Output Format Counters 
    Bytes Written=23

    在Windows环境运行样例代码时会出现下面的异常,但是不影响业务:

    java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

  • 通过MapReduce服务的WebUI进行查看

    使用具有任务查看权限的用户登录FusionInsight Manager,单击“集群 > 待操作集群的名称 > 服务 > Mapreduce > JobHistoryServer”进入Web界面后查看任务执行状态。

    图1 JobHistory Web UI界面
  • 通过YARN服务的WebUI进行查看
    使用具有任务查看权限的用户登录FusionInsight Manager,单击“集群 > 待操作集群的名称 > 服务 > Yarn > ResourceManager(主)”进入Web界面后查看任务执行状态。
    图2 ResourceManager Web UI页面
  • 查看MapReduce日志获取应用运行情况

    您可以查看MapReduce日志了解应用运行情况,并根据日志信息调整应用程序。

分享:

    相关文档

    相关产品