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

在Linux环境中调测MapReduce应用

操作场景

在程序代码完成开发后,可以在Linux环境中运行应用。

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

  • 通过运行结果查看程序运行情况。
  • 登录MapReduce WebUI查看应用程序运行情况。
  • 登录Yarn WebUI查看应用程序运行情况
  • 通过MapReduce日志获取应用程序运行情况。

运行程序

  1. 进入样例工程本地根目录,在Windows命令提示符窗口中执行下面命令进行打包。

    mvn -s "{maven_setting_path}" clean package

    • 上述打包命令中的{maven_setting_path}为本地Maven的setting.xml文件路径。
    • 打包成功之后,在工程根目录的target子目录下获取打好的jar包,例如“MRTest-XXX.jar”,jar包名称以实际打包结果为准。

  2. 上传生成的应用包“MRTest-XXX.jar”到Linux客户端上,例如/opt/client/conf,与配置文件位于同一目录下。
  3. 在Linux环境下运行样例工程。

    • 对于MapReduce统计样例程序,执行如下命令。

      yarn jar MRTest-XXX.jar com.huawei.bigdata.mapreduce.examples.FemaleInfoCollector <inputPath> <outputPath>

      此命令包含了设置参数和提交job的操作,其中<inputPath>指HDFS文件系统中input的路径,<outputPath>指HDFS文件系统中output的路径。

      • 在执行yarn jar MRTest-XXX.jar com.huawei.bigdata.mapreduce.examples.FemaleInfoCollector <inputPath> <outputPath>命令之前,需要把log1.txt和log2.txt这两个文件上传到HDFS的<inputPath>目录下。参考MapReduce统计样例程序开发思路
      • 在执行yarn jar MRTest-XXX.jar com.huawei.bigdata.mapreduce.examples.FemaleInfoCollector <inputPath> <outputPath>命令之前,<outputPath>目录必须不存在,否则会报错。
      • 在MapReduce任务运行过程中禁止重启HDFS服务,否则可能会导致任务失败。
    • 对于MapReduce访问多组件样例程序,操作步骤如下。
      1. 获取“hbase-site.xml”、“hiveclient.properties”和“hive-site.xml”这三个配置文件,并在Linux环境上创建文件夹保存这三个配置文件,例如“/opt/client/conf”。

        “hbase-site.xml”从HBase客户端获取,“hiveclient.properties”和“hive-site.xml”从Hive客户端获取。

      2. 在Linux环境中添加样例工程运行所需的classpath,例如

        export YARN_USER_CLASSPATH=/opt/client/conf:/opt/client/HBase/hbase/lib/*:/opt/client/HBase/hbase/lib/client-facing-thirdparty/*:/opt/client/Hive/Beeline/lib/*

      3. 提交MapReduce任务,执行如下命令,运行样例工程。

        yarn jar MRTest-XXX.jar com.huawei.bigdata.mapreduce.examples.MultiComponentExample

查看调测结果

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

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

    图1 JobHistory Web UI界面
  • 通过YARN服务的WebUI进行查看
    使用具有任务查看权限的用户登录FusionInsight Manager,单击“集群 > 待操作集群的名称 > 服务 > Yarn > ResourceManager(主)”进入Web界面后查看任务执行状态。
    图2 ResourceManager Web UI页面
  • 查看MapReduce应用运行结果数据。
    • 当用户在Linux环境下执行yarn jar MRTest-XXX.jar命令后,可以通过执行结果显示正在执行的应用的运行情况。例如:
      yarn jar MRTest-XXX.jar /tmp/mapred/example/input/ /tmp/root/output/1
      16/07/12 17:07:16 INFO hdfs.PeerCache: SocketCache disabled.
      16/07/12 17:07:17 INFO input.FileInputFormat: Total input files to process : 2
      16/07/12 17:07:18 INFO mapreduce.JobSubmitter: number of splits:2
      16/07/12 17:07:18 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1468241424339_0006
      16/07/12 17:07:18 INFO impl.YarnClientImpl: Submitted application application_1468241424339_0006
      16/07/12 17:07:18 INFO mapreduce.Job: The url to track the job: http://10-120-180-170:8088/proxy/application_1468241424339_0006/
      16/07/12 17:07:18 INFO mapreduce.Job: Running job: job_1468241424339_0006
      16/07/12 17:07:31 INFO mapreduce.Job: Job job_1468241424339_0006 running in uber mode : false
      16/07/12 17:07:31 INFO mapreduce.Job:  map 0% reduce 0%
      16/07/12 17:07:41 INFO mapreduce.Job:  map 50% reduce 0%
      16/07/12 17:07:43 INFO mapreduce.Job:  map 100% reduce 0%
      16/07/12 17:07:51 INFO mapreduce.Job:  map 100% reduce 100%
      16/07/12 17:07:51 INFO mapreduce.Job: Job job_1468241424339_0006 completed successfully
      16/07/12 17:07:51 INFO mapreduce.Job: Counters: 49
              File System Counters
                      FILE: Number of bytes read=75
                      FILE: Number of bytes written=435659
                      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)=144984
                      Total time spent by all reduces in occupied slots (ms)=56280
                      Total time spent by all map tasks (ms)=18123
                      Total time spent by all reduce tasks (ms)=7035
                      Total vcore-milliseconds taken by all map tasks=18123
                      Total vcore-milliseconds taken by all reduce tasks=7035
                      Total megabyte-milliseconds taken by all map tasks=74231808
                      Total megabyte-milliseconds taken by all reduce tasks=28815360
              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)=202
                      CPU time spent (ms)=2720
                      Physical memory (bytes) snapshot=1595645952
                      Virtual memory (bytes) snapshot=12967759872
                      Total committed heap usage (bytes)=2403860480
              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
    • 在Linux环境下执行yarn application -status <ApplicationID> ,可以通过执行结果显示正在执行的应用的运行情况。例如:
      yarn application -status application_1468241424339_0006
      Application Report : 
              Application-Id : application_1468241424339_0006
              Application-Name : Collect Female Info
              Application-Type : MAPREDUCE
              User : root
              Queue : default
              Start-Time : 1468314438442
              Finish-Time : 1468314470080
              Progress : 100%
              State : FINISHED
              Final-State : SUCCEEDED
              Tracking-URL : http://10-120-180-170:19888/jobhistory/job/job_1468241424339_0006
              RPC Port : 27100
              AM Host : 10-120-169-46
              Aggregate Resource Allocation : 172153 MB-seconds, 64 vcore-seconds
              Log Aggregation Status : SUCCEEDED
              Diagnostics : Application finished execution. 
              Application Node Label Expression : <Not set>
              AM container Node Label Expression : <DEFAULT_PARTITION>
  • 查看MapReduce日志获取应用运行情况。

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

分享:

    相关文档

    相关产品