
# 在本地Windows环境中调测MapReduce应用
#### 操作场景
在程序代码完成开发后，您可以在Windows环境中运行应用。本地和集群业务平面网络互通时，您可以直接在本地进行调测。
MapReduce应用程序运行完成后，可通过如下方式查看应用程序的运行情况。
- 在IntelliJ IDEA中查看应用程序运行情况。
- 通过MapReduce日志获取应用程序运行情况。
- 登录MapReduce WebUI查看应用程序运行情况。
- 登录Yarn WebUI查看应用程序运行情况。
![](https://support.huaweicloud.com/devg-lts-mrs/public_sys-resources/note_3.0-zh-cn.png)
在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()"运行应用工程。 
   ![](https://support.huaweicloud.com/devg-lts-mrs/public_sys-resources/note_3.0-zh-cn.png)
   如果集群开启了ZooKeeper SSL，则运行该样例前，需要检查配置文件mapred-site.xml（[准备运行环境](https://support.huaweicloud.com/devg-lts-mrs/mrs_07_360006.html#mrs_07_360006__section114783616307)中样例工程的"conf"配置文件目录中获取）的配置项"mapreduce.admin.map.child.java.opts"和"mapreduce.admin.reduce.child.java.opts"是否包含如下内容：
   ```
   -Dzookeeper.client.secure=true -Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty
   ```
   如果不包含，将上述内容添加到配置项末尾处。
   
   
 
#### 查看调测结果
- **查看运行结果获取应用运行情况**
  如下所示，通过控制台输出结果查看应用运行情况。
  ```
  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
  ```
  ![](https://support.huaweicloud.com/devg-lts-mrs/public_sys-resources/note_3.0-zh-cn.png)
  在Windows环境运行样例代码时会出现下面的异常，但是不影响业务：
  java.io.IOException: Could not locate executable null\\bin\\winutils.exe in the Hadoop binaries.
  
- **通过MapReduce服务的WebUI进行查看**
  使用具有任务查看权限的用户登录FusionInsight Manager，选择"集群 \> *待操作集群的名称* \> 服务 \> Mapreduce ＞ JobHistoryServer"进入Web界面后查看任务执行状态。
  图1JobHistory Web UI界面   
  ![](https://support.huaweicloud.com/devg-lts-mrs/zh-cn_image_0000001909404778.png "点击放大") 
- **通过YARN服务的WebUI进行查看**
  使用具有任务查看权限的用户登录FusionInsight Manager，选择"集群 \>*待操作集群的名称* \> 服务 \> Yarn \> ResourceManager(主)"进入Web界面后查看任务执行状态。
  图2ResourceManager Web UI页面   
  ![](https://support.huaweicloud.com/devg-lts-mrs/zh-cn_image_0000001943683985.png "点击放大") 
- **查看MapReduce日志获取应用运行情况**
  您可以查看MapReduce日志了解应用运行情况，并根据日志信息调整应用程序。
  
 
