[转帖]用Hadoop管理界面来分析Map-Reduce作业_Hadoop,ERP及大数据讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Hadoop,ERP及大数据讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2838 | 回复: 0   主题: [转帖]用Hadoop管理界面来分析Map-Reduce作业        下一篇 
huizai
注册用户
等级:少校
经验:933
发帖:83
精华:0
注册:2013-6-18
状态:离线
发送短消息息给huizai 加好友    发送短消息息给huizai 发消息
发表于: IP:您无权察看 2013-6-25 15:27:05 | [全部帖] [楼主帖] 楼主

如果我们只是在IDE里面跑Hadoop作业,那么这个作业的运行过程不会显示在Hadoop  管理界面上,但是如果我们把作业上传到服务器上运行,那么作业的运行过程就会显示在管理界面上。

还是以上次的分析最高气温的Map-Reduce为例,源代码可以见http://supercharles888.blog.51cto.com/609344/878422 这篇博客的内容。我们将其打包成jar包,然后上传到/home/hadoop-user/hadoop-0.20.2/charlestest 目录中:

北京联动北方科技有限公司

我们在命令行中执行MaxTemperature类中定义的作业:

hadoop jar ParseWeatherFile.jar com.charles.parseweather.MaxTemperature  input/1901.txt output-001


这里我们执行的入口为 WeatherFile的 jar包中的MaxTemperature类,最后2个参数分别是输入文件位置和输出目录:

运行结果如图:

北京联动北方科技有限公司

现在我们就可以去控制台去看整个过程了:

我们去http://192.168.129.35:50030/jobtracker.jsp 来看map-reduce过程。

在Completed Job部分,我们看到了刚才运行的作业:

北京联动北方科技有限公司

对比Job Name刚好是我们在job类中设定的名字,见第43行所示:

  1. package com.charles.parseweather; 
  2. import org.apache.hadoop.conf.Configuration; 
  3. import org.apache.hadoop.fs.Path; 
  4. import org.apache.hadoop.io.IntWritable; 
  5. import org.apache.hadoop.io.Text; 
  6. import org.apache.hadoop.mapreduce.Job; 
  7. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; 
  8. import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; 
  9. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 
  10. import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; 
  11. public class MaxTemperature { 
  12.  
  13.  
  14.  public static void main(String[] args) throws Exception{ 
  15.  // TODO Auto-generated method stub 
  16.  
  17.  
  18.  if (args.length !=2){ 
  19.  System.err.println("Usage: MaxTemperature <input path> <output path>"); 
  20.  System.exit(-1); 
  21.  } 
  22.  
  23.  //创建一个Map-Reduce的作业 
  24.  Configuration conf = new Configuration(); 
  25.  conf.set("hadoop.job.ugi", "hadoop-user,hadoop-user"); 
  26.  
  27.  Job job = new Job(conf,"Get Maximum Weather Information! ^_^"); 
  28.  
  29.  //设定作业的启动类/ 
  30.  job.setJarByClass(MaxTemperature.class); 
  31.  
  32.  //解析输入和输出参数,分别作为作业的输入和输出,都是文件 
  33.  FileInputFormat.addInputPath(job, new Path(args[0])); 
  34.  FileOutputFormat.setOutputPath(job, new Path(args[1])); 
  35.  
  36.  //配置作业,设定Mapper类,Reducer类 
  37.  job.setMapperClass(MaxTemperatureMapper.class); 
  38.  job.setReducerClass(MaxTemperatureReducer.class); 
  39.  job.setOutputKeyClass(Text.class); 
  40.  job.setOutputValueClass(IntWritable.class); 
  41.  
  42.  System.exit(job.waitForCompletion(true)?0:1); 
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  } 
  50.  

;

我们点进去,则可以看到Map-Reduce的更多细节:

北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论