1. 将开发好MR代码打包成jar。添加到distributed cache中。
bin/hadoop fs -copyFromLocal /root/stat-analysis-mapred-1.0-SNAPSHOT.jar /user/root/lib
2. 在服务器端创建和你客户端一模一样的用户。创建目录 /tmp/hadoop-root/stagging/用户
3. 客户端提交job的代码
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "node.tracker1");
conf.set("fs.default.name", "hdfs://node.tracker1:9000/hbase");
conf.set("mapred.job.tracker", "node.tracker1:9001");
Job job = new Job(conf, "Hbase_FreqCounter1");
job.setJarByClass(FreqCounter1.class);
Scan scan = new Scan();
String columns = "details"; // comma seperated
scan.addFamily(Bytes.toBytes(columns));
scan.setFilter(new FirstKeyOnlyFilter());
TableMapReduceUtil.initTableMapperJob("access_logs", scan, Mapper1.class, ImmutableBytesWritable.class,
IntWritable.class, job);
TableMapReduceUtil.initTableReducerJob("summary_user", Reducer1.class, job);
/ TableMapReduceUtil.addDependencyJars(job);
DistributedCache.addFileToClassPath(new Path("hdfs://node.tracker1:9000/user/root/lib/stat-analysis-mapred-1.0-SNAPSHOT.jar"),job.getConfiguration());
job.submit();
4.运行java application,登陆node的MR管理页面,可以看到