如何在eclipse里方便的读hadoop源码下载

&>&&>&&>&&>&如何把hadoop源码关联到eclipse工程中
如何把hadoop源码关联到eclipse工程中
上传大小:330KB
如何把hadoop源码关联到eclipse工程中
嵌到我的页面
<input type="text" value="">
综合评分:0(0位用户评分)
所需积分:1
下载次数:4
审核通过送C币
创建者:id_rin
创建者:qq_
创建者:qq_
课程推荐相关知识库
上传者其他资源上传者专辑
开发技术热门标签
VIP会员动态
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
android服务器底层网络模块的设计方法
所需积分:0
剩余积分:720
您当前C币:0
可兑换下载积分:0
兑换下载分:
兑换失败,您当前C币不够,请先充值C币
消耗C币:0
你当前的下载分为234。
如何把hadoop源码关联到eclipse工程中
会员到期时间:
剩余下载次数:
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可奖励20下载分
被举报人:
aladdinwxl
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:如何使用eclipse调试Hadoop作业 - Eclipse Hadoop 调试 - ITeye
qindongliang1922
发表时间:
使用eclipse来调试hadoop作业是非常简洁方便的,散仙以前也有用eclipse开发过hadoop程序,但是一直没有深入了解eclipse调试的一些模式,有些时候也会出一些莫名奇妙的异常,最常见的就是下面这个
&pre name="code" class="java"&java.lang.RuntimeException: java.lang.ClassNotFoundException: com.qin.sort.TestSort$SMapper
at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:857)
at org.apache.hadoop.mapreduce.JobContext.getMapperClass(JobContext.java:199)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:718)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)&/pre&
这个异常是最莫名其妙的一个,明明自己的MR类里面有这个Mapper的内部类,但是一运行程序,就报这个异常,说找不到这个类,然后就百般查找问题,找来找去,也没找出个所以然。
其实这并不是程序的问题,而是对eclipse的调试模式不够了解的问题,eclipse上运行hadoop总的来说有2种模式,第一种就是Local模式,也叫本地模式,第二种就是我们正式的线上集群模式,当运行本地模式的时候,程序并不会被提交到Hadoop集群上,而是基于单机的模式跑的,但是单机的模式,运行的结果仍在是存储在HDFS上的,只不过没有利用hadoop集群的资源,单机的模式不要提交jar包到hadoop集群上,因此一般我们使用local来测试我们的MR程序是否能够正常运行,
下面我们来看下,基于Local模式跑的一个排序作业:
&pre name="code" class="java"&
排序数据:
a 784
b 12
c -11
dd 99999
&/pre&
程序源码:
&pre name="code" class="java"&package com.qin.
import java.io.IOE
import org.apache.hadoop.conf.C
import org.apache.hadoop.fs.FileS
import org.apache.hadoop.fs.P
import org.apache.hadoop.io.IntW
import org.apache.hadoop.io.LongW
import org.apache.hadoop.io.T
import org.apache.hadoop.io.WritableC
import org.apache.hadoop.mapred.JobC
import org.apache.hadoop.mapreduce.J
import org.apache.hadoop.mapreduce.M
import org.apache.hadoop.mapreduce.R
import org.apache.hadoop.mapreduce.lib.input.FileInputF
import org.apache.hadoop.mapreduce.lib.output.FileOutputF
* 测试排序的
* MR作业类
* QQ技术交流群:
* @author qindongliang
* **/
public class TestSort {
private static class SMapper extends Mapper&LongWritable, Text, IntWritable, Text&{
private Text text=new Text();//输出
private static final IntWritable one=new IntWritable();
protected void map(LongWritable key, Text value,Context context)
throws IOException, InterruptedException {
String s=value.toString();
//System.out.println("abc: "+s);
// if((s.trim().indexOf(" ")!=-1)){
String ss[]=s.split(" ");
one.set(Integer.parseInt(ss[1].trim()));//
text.set(ss[0].trim());&
context.write(one, text);
* Reduce类
private static class SReduce extends Reducer&IntWritable, Text, Text, IntWritable&{
private Text text=new Text();
protected void reduce(IntWritable arg0, Iterable&Text& arg1,Context context)
throws IOException, InterruptedException {
for(Text t:arg1){
text.set(t.toString());
context.write(text, arg0);
& * 排序的类
private static class SSort extends WritableComparator{
public SSort() {
super(IntWritable.class,true);//注册排序组件
public int compare(byte[] arg0, int arg1, int arg2, byte[] arg3,
int arg4, int arg5) {
* 控制升降序的关键控制-号是降序
return -pare(arg0, arg1, arg2, arg3, arg4, arg5);//注意使用负号来完成降序
public int compare(Object a, Object b) {
return&&& -pare(a, b);//注意使用负号来完成降序
& * main方法
public static void main(String[] args) throws Exception{
String inputPath="hdfs://192.168.75.130:9000/root/output"; &&&
& String outputPath="hdfs://192.168.75.130:9000/root/outputsort";
& JobConf conf=new JobConf();
//Configuration conf=new Configuration();
&& //在你的文件地址前自动添加:hdfs://master:9000/
// conf.set("fs.default.name", "hdfs://192.168.75.130:9000");
& //指定jobtracker的ip和端口号,master在/etc/hosts中可以配置
//& conf.set("mapred.job.tracker","192.168.75.130:9001");
// conf.get("mapred.job.tracker");
System.out.println("模式:& "+conf.get("mapred.job.tracker"));
//& conf.setJar("tt.jar");
& FileSystem& fs=FileSystem.get(conf);
& Path pout=new Path(outputPath);
& if(fs.exists(pout)){
& fs.delete(pout, true);
& System.out.println("存在此路径, 已经删除......");
& Job job=new Job(conf, "sort123");
&&&&&&&&& job.setJarByClass(TestSort.class);
&&&&&&&&& job.setOutputKeyClass(IntWritable.class);//告诉map,reduce输出K,V的类型
&&&&&&&&& FileInputFormat.setInputPaths(job, new Path(inputPath));& //输入路径
&&&&&&&&& FileOutputFormat.setOutputPath(job, new Path(outputPath));//输出路径&
&&&&&&&&& job.setMapperClass(SMapper.class);//map类
&&&&&&&&& job.setReducerClass(SReduce.class);//reduce类
&&&&&&&&& job.setSortComparatorClass(SSort.class);//排序类
//&&&&&&&&& job.setInputFormatClass(org.apache.hadoop.mapreduce.lib.input.TextInputFormat.class);
//
& job.setOutputFormatClass(TextOutputFormat.class);
&&&&&&&&& System.exit(job.waitForCompletion(true) ? 0 : 1);&
}
&/pre&
打印结果如下:
&pre name="code" class="java"&模式:& local
存在此路径, 已经删除......
WARN - NativeCodeLoader.&clinit&(52) | Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
WARN - JobClient.copyAndConfigureFiles(746) | Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
WARN - JobClient.copyAndConfigureFiles(870) | No job jar file set.& User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
INFO - FileInputFormat.listStatus(237) | Total input paths to process : 1
WARN - LoadSnappy.&clinit&(46) | Snappy native library not loaded
INFO - JobClient.monitorAndPrintJob(1380) | Running job: job_local_0001
INFO - LocalJobRunner$Job.run(340) | Waiting for map tasks
INFO - LocalJobRunner$Job$MapTaskRunnable.run(204) | Starting task: attempt_local_0001_m_
INFO - Task.initialize(534) |& Using ResourceCalculatorPlugin : null
INFO - MapTask.runNewMapper(729) | Processing split: hdfs://192.168.75.130:9000/root/output/sort.txt:0+28
INFO - MapTask$MapOutputBuffer.&init&(949) | io.sort.mb = 100
INFO - MapTask$MapOutputBuffer.&init&(961) | data buffer = 14720
INFO - MapTask$MapOutputBuffer.&init&(962) | record buffer = 680
INFO - MapTask$MapOutputBuffer.flush(1289) | Starting flush of map output
INFO - MapTask$MapOutputBuffer.sortAndSpill(1471) | Finished spill 0
INFO - Task.done(858) | Task:attempt_local_0001_m_ is done. And is in the process of commiting
INFO - LocalJobRunner$Job.statusUpdate(466) |
INFO - Task.sendDone(970) | Task 'attempt_local_0001_m_' done.
INFO - LocalJobRunner$Job$MapTaskRunnable.run(229) | Finishing task: attempt_local_0001_m_
INFO - LocalJobRunner$Job.run(348) | Map task executor complete.
INFO - Task.initialize(534) |& Using ResourceCalculatorPlugin : null
INFO - LocalJobRunner$Job.statusUpdate(466) |
INFO - Merger$MergeQueue.merge(408) | Merging 1 sorted segments
INFO - Merger$MergeQueue.merge(491) | Down to the last merge-pass, with 1 segments left of total size: 35 bytes
INFO - LocalJobRunner$Job.statusUpdate(466) |
INFO - Task.done(858) | Task:attempt_local_0001_r_ is done. And is in the process of commiting
INFO - LocalJobRunner$Job.statusUpdate(466) |
INFO - mit(1011) | Task attempt_local_0001_r_ is allowed to commit now
INFO - mitTask(173) | Saved output of task 'attempt_local_0001_r_' to hdfs://192.168.75.130:9000/root/outputsort
INFO - LocalJobRunner$Job.statusUpdate(466) | reduce & reduce
INFO - Task.sendDone(970) | Task 'attempt_local_0001_r_' done.
INFO - JobClient.monitorAndPrintJob(1393) |& map 100% reduce 100%
INFO - JobClient.monitorAndPrintJob(1448) | Job complete: job_local_0001
INFO - Counters.log(585) | Counters: 19
INFO - Counters.log(587) |&& File Output Format Counters
INFO - Counters.log(589) |&&&& Bytes Written=26
INFO - Counters.log(587) |&& File Input Format Counters
INFO - Counters.log(589) |&&&& Bytes Read=28
INFO - Counters.log(587) |&& FileSystemCounters
INFO - Counters.log(589) |&&&& FILE_BYTES_READ=393
INFO - Counters.log(589) |&&&& HDFS_BYTES_READ=56
INFO - Counters.log(589) |&&&& FILE_BYTES_WRITTEN=135742
INFO - Counters.log(589) |&&&& HDFS_BYTES_WRITTEN=26
INFO - Counters.log(587) |&& Map-Reduce Framework
INFO - Counters.log(589) |&&&& Map output materialized bytes=39
INFO - Counters.log(589) |&&&& Map input records=4
INFO - Counters.log(589) |&&&& Reduce shuffle bytes=0
INFO - Counters.log(589) |&&&& Spilled Records=8
INFO - Counters.log(589) |&&&& Map output bytes=25
INFO - Counters.log(589) |&&&& Total committed heap usage (bytes)=
INFO - Counters.log(589) |&&&& Combine input records=0
INFO - Counters.log(589) |&&&& SPLIT_RAW_BYTES=112
INFO - Counters.log(589) |&&&& Reduce input records=4
INFO - Counters.log(589) |&&&& Reduce input groups=4
INFO - Counters.log(589) |&&&& Combine output records=0
INFO - Counters.log(589) |&&&& Reduce output records=4
INFO - Counters.log(589) |&&&& Map output records=4
&/pre&
排序结果如下:
&pre name="code" class="java"&dd 99999
a 784
b 12
c -11
&/pre&
单机模式调试通过之后,我们就可以考虑采用hadoop集群的模式来跑,这时候有2种方式,可以来完成这件事,第一是,为了方便将整个项目打成一个jar包,上传到Linux上,然后执行shell命令:
bin/hadoop jar tt.jar com.qin.sort.TestSort
来进行测试,注意,散仙是为了方便,路径是写死在程序里面所以后面不用输入,输入和输出路径,正式的开发,为了灵活性,一般会通过外部传产来指定输入和输出路径。
第二种方式,也比较方便,直接在eclipse中提交到hadoop集群作业中,不过即使是使用eclipse来提交作业,还是需要将整个项目打成一个jar包,只不过这时是eclipse帮我们提交作业的,这样我们就可以Win平台上直接提交运行hadoop作业了,但是主流的还是使用上传jar包的方式。关于把整个项目打成一个jar包,散仙在后面会上传一个ant脚本,直接执行它就可以了,这样就可以把有依赖关系的类打在一起,把一整个项目做为一个整体,在hadoop上,只需要指定jar,指定类的全名称,和输入,输出路径即可。ant的脚本内容如下:
&pre name="code" class="xml"&
&project name="${component.name}" basedir="." default="jar"&
&property environment="env"/&
&property name="hadoop.home" value="${env.HADOOP_HOME}"/&
&property name="hadoop.home" value="D:/hadoop-1.2.0"/&
&!-- 指定jar包的名字 --&
&property name="jar.name" value="tt.jar"/&
&path id="project.classpath"&
&fileset dir="lib"&
&include name="*.jar" /&
&/fileset&
&fileset dir="${hadoop.home}"&
&include name="**/*.jar" /&
&/fileset&
&target name="clean" &
&delete dir="bin" failonerror="false" /&
&mkdir dir="bin"/&
&target name="build" depends="clean"&
&echo message="${ant.project.name}: ${ant.file}"/&
&javac destdir="bin" encoding="utf-8" debug="true" includeantruntime="false" debuglevel="lines,vars,source"&
&&&&&&&&&&& &src path="src"/&
&exclude name="**/.svn" /&
&&&&&&&&&&& &classpath refid="project.classpath"/&
&&&&&&& &/javac&
&copy todir="bin"&
&fileset dir="src"&
&include name="*config*"/&
&/fileset&
&target name="jar" depends="build"&
&copy todir="bin/lib"&
&fileset dir="lib"&
&include name="**/*.*"/&
&/fileset&
&path id="lib-classpath"&
&fileset dir="lib" includes="**/*.jar" /&
&pathconvert property="my.classpath" pathsep=" " &
&chainedmapper&
&!-- 移除绝对路径 --&
&flattenmapper /&
&!-- 加上lib前缀 --&
&globmapper from="*" to="lib/*" /&
&&&&&& &/chainedmapper&
&&&& &/mapper&
&&&& &path refid="lib-classpath" /&
&/pathconvert&
&jar basedir="bin" destfile="${jar.name}" &
&include name="**/*"/&
&!-- define MANIFEST.MF --&
&manifest&
&attribute name="Class-Path" value="${my.classpath}" /&
&/manifest&
&/target&
&/project&
&/pre&
运行上面的这个ant脚本之后,我们的项目就会被打成一个jar包,截图如下:
jar包有了之后,我们先测试在eclipse上如何把作业提交到hadoop集群上,只要把main方面的代码,稍加改动即可:
&pre name="code" class="java"& /**
& * main方法
public static void main(String[] args) throws Exception{
String inputPath="hdfs://192.168.75.130:9000/root/output"; &&&
& String outputPath="hdfs://192.168.75.130:9000/root/outputsort";
& JobConf conf=new JobConf();
//Configuration conf=new Configuration();//可以使用这个conf来测试Local模式
//如果在src目录下有,mapred-site.xml文件,就不要此行代码
//注意此行代码也是在非Local模式下才使用
conf.set("mapred.job.tracker","192.168.75.130:9001");
// conf.get("mapred.job.tracker");
System.out.println("模式:& "+conf.get("mapred.job.tracker"));
// conf.setJar("tt.jar"); 非Local模式下使用
& FileSystem& fs=FileSystem.get(conf);
& Path pout=new Path(outputPath);
& if(fs.exists(pout)){
& fs.delete(pout, true);
& System.out.println("存在此路径, 已经删除......");
& Job job=new Job(conf, "sort123");
&&&&&&&&& job.setJarByClass(TestSort.class);
&&&&&&&&& job.setOutputKeyClass(IntWritable.class);//告诉map,reduce输出K,V的类型
&&&&&&&&& FileInputFormat.setInputPaths(job, new Path(inputPath));& //输入路径
&&&&&&&&& FileOutputFormat.setOutputPath(job, new Path(outputPath));//输出路径&
&&&&&&&&& job.setMapperClass(SMapper.class);//map类
&&&&&&&&& job.setReducerClass(SReduce.class);//reduce类
&&&&&&&&& job.setSortComparatorClass(SSort.class);//排序类
//&&&&&&&&& job.setInputFormatClass(org.apache.hadoop.mapreduce.lib.input.TextInputFormat.class);
//
& job.setOutputFormatClass(TextOutputFormat.class);
&&&&&&&&& System.exit(job.waitForCompletion(true) ? 0 : 1);&
运行程序,输出,如下:
&pre name="code" class="java"&模式:& 192.168.75.130:9001
存在此路径, 已经删除......
WARN - JobClient.copyAndConfigureFiles(746) | Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
INFO - FileInputFormat.listStatus(237) | Total input paths to process : 1
WARN - NativeCodeLoader.&clinit&(52) | Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
WARN - LoadSnappy.&clinit&(46) | Snappy native library not loaded
INFO - JobClient.monitorAndPrintJob(1380) | Running job: job__0035
INFO - JobClient.monitorAndPrintJob(1393) |& map 0% reduce 0%
INFO - JobClient.monitorAndPrintJob(1393) |& map 100% reduce 0%
INFO - JobClient.monitorAndPrintJob(1393) |& map 100% reduce 33%
INFO - JobClient.monitorAndPrintJob(1393) |& map 100% reduce 100%
INFO - JobClient.monitorAndPrintJob(1448) | Job complete: job__0035
INFO - Counters.log(585) | Counters: 29
INFO - Counters.log(587) |&& Job Counters
INFO - Counters.log(589) |&&&& Launched reduce tasks=1
INFO - Counters.log(589) |&&&& SLOTS_MILLIS_MAPS=8498
INFO - Counters.log(589) |&&&& Total time spent by all reduces waiting after reserving slots (ms)=0
INFO - Counters.log(589) |&&&& Total time spent by all maps waiting after reserving slots (ms)=0
INFO - Counters.log(589) |&&&& Launched map tasks=1
INFO - Counters.log(589) |&&&& Data-local map tasks=1
INFO - Counters.log(589) |&&&& SLOTS_MILLIS_REDUCES=9667
INFO - Counters.log(587) |&& File Output Format Counters
INFO - Counters.log(589) |&&&& Bytes Written=26
INFO - Counters.log(587) |&& FileSystemCounters
INFO - Counters.log(589) |&&&& FILE_BYTES_READ=39
INFO - Counters.log(589) |&&&& HDFS_BYTES_READ=140
INFO - Counters.log(589) |&&&& FILE_BYTES_WRITTEN=117654
INFO - Counters.log(589) |&&&& HDFS_BYTES_WRITTEN=26
INFO - Counters.log(587) |&& File Input Format Counters
INFO - Counters.log(589) |&&&& Bytes Read=28
INFO - Counters.log(587) |&& Map-Reduce Framework
INFO - Counters.log(589) |&&&& Map output materialized bytes=39
INFO - Counters.log(589) |&&&& Map input records=4
INFO - Counters.log(589) |&&&& Reduce shuffle bytes=39
INFO - Counters.log(589) |&&&& Spilled Records=8
INFO - Counters.log(589) |&&&& Map output bytes=25
INFO - Counters.log(589) |&&&& Total committed heap usage (bytes)=
INFO - Counters.log(589) |&&&& CPU time spent (ms)=1140
INFO - Counters.log(589) |&&&& Combine input records=0
INFO - Counters.log(589) |&&&& SPLIT_RAW_BYTES=112
INFO - Counters.log(589) |&&&& Reduce input records=4
INFO - Counters.log(589) |&&&& Reduce input groups=4
INFO - Counters.log(589) |&&&& Combine output records=0
INFO - Counters.log(589) |&&&& Physical memory (bytes) snapshot=
INFO - Counters.log(589) |&&&& Reduce output records=4
INFO - Counters.log(589) |&&&& Virtual memory (bytes) snapshot=
INFO - Counters.log(589) |&&&& Map output records=4
&/pre&
我们可以看出,运行正常,排序的内容如下:
&pre name="code" class="java"&dd 99999
a 784
b 12
c -11
&/pre&
结果和local模式下的一样,还有一个与local模式不同的地方是,我们可以在http://192.168.75.130:50030/jobtracker.jsp的任务页面上找到刚才执行的任务状况,这一点在Local模式下运行程序,是没有的。/size]
[size=large]最后,散仙再来看下,如何将jar包,上传到Linux提交作业到hadoop集群上。刚才,我们已经把jar给打好了,现在只需上传到linux上即可:
然后开始执行shell命令运行程序:
到此,我们已经完美的执行成功,最后一点需要注意的是,在执行排序任务时,如果出现异常:
&pre name="code" class="java"&java.lang.Exception: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.LongWritable, recieved org.apache.hadoop.io.IntWritable
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:354)
Caused by: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.LongWritable, recieved org.apache.hadoop.io.IntWritable
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:1019)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:690)
at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80)
at com.qin.sort.TestSort$SMapper.map(TestSort.java:51)
at com.qin.sort.TestSort$SMapper.map(TestSort.java:1)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:223)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)&/pre&
这个异常的出现,多半是因为,我们没有指定输出的Key,或者Value,或者指定的类型不一致,导致,我们只需要正确的设置输出的Key或者Value的类型即可.
&pre name="code" class="java"&
job.setOutputKeyClass(IntWritable.class);
&& job.setOutputValueClass(Text.class);&/pre&
设置完后,就可以正常测试运行了。
(878 Bytes)
下载次数: 19Hadoop 源码下载,编译,install,导入eclipse - 平衡
trade-off - ITeye技术网站
博客分类:
1,准备好环境
首现操作系统最好还是LINUX,WINDOWS上搞起来太麻烦
JDK1.5必须的,最好JDK1.6也准备好。以备版本升级的时候需要用
svn 1.5版本的或者以上的
eclipse http://www.eclipse.org/ 上下载 ||| eclipse的svn插件
ant http://ant.apache.org/ 下载
ivy http://ant.apache.org/ivy/ 下载,下载完后放在 ant的lib目录下,因为ivy是ant的一个子工程
forrest http://forrest.apache.org/mirrors.cgi#how
用于编译生成文档的类库
准备好以上环境,就差不多了。
2,下载源代码
注意存放目录:
比方我的目录结构是
/home/txy/work/hadoop
(存放common)
/home/txy/work/hadoop/hdfs (存放hdfs)
/home/txy/work/hadoop/mapred (存放mapred)
可以执行以下命令:
cd /home/txy/work
svn co http://svn.apache.org/repos/asf/hadoop/common/trunk hadoop
cd /home/txy/work/hadoop/
svn co http://svn.apache.org/repos/asf/hadoop/hdfs/trunk/ hdfs
cd /home/txy/work/hadoop/
svn co http://svn.apache.org/repos/asf/hadoop/mapreduce/trunk
为什么要这样的目录结构呢?原因具体可以看hadoop/bin/hadoop-config.sh,看懂了之后当然也可以随意修改路径了
3,编译源代码,并发布到maven 的本地库
分别进入到上面三个目录中,进行编译:
cd /home/txy/work/hadoop/
ant package -Djava5.home=/home/txy/software/jdk1.5.0_07 -Dforrest.home=/home/txy/software/apache-forrest-0.8
cd /home/txy/work/hadoop/hdfs/
ant package -Djava5.home=/home/txy/software/jdk1.5.0_07 -Dforrest.home=/home/txy/software/apache-forrest-0.8
cd /home/txy/work/hadoop/
ant package -Djava5.home=/home/txy/software/jdk1.5.0_07 -Dforrest.home=/home/txy/software/apache-forrest-0.8
这里的java5.home 和 forrest.home随各自电脑上安装的实际路径为准。
发布到本地maven 库在以上各目录中执行:
ant mvn-install 就可以了,那么我们写 程序的时候就可以用maven把这个库引进来了。
4,导入eclipse
创建eclipse工程在创建之前,现设置:project --》build Automaticaly 勾掉,不要让它自动build
new --》java project --》create project from existing source--》 选择CO下来的目录 --》finish
导入之后,右键各工程的build.xml --》 build...--》
如果build common: use the eclipse-files and compile-core-test targets
如果build hdfs: use the targets compile, compile-hdfs-test, and eclipse-files
如果build MapRedues, use the targets compile, compile-mapreduce-test, and eclipse-files
命令行 ant eclipse-files执行就可以了,然后eclipse中File--&import--&exsiting projects into workspace就可以了,不过建议还是不要build Automaticaly,要不然太麻烦了。
这样源代码就导入进来了,可以查看和修改了。
以上内容也可以参见:
开发mapReduce程序的eclipse插件:
这个eclipse插件编译的问题还是没搞定,纠结中,看了官方网站是说:
首先在家目录下添加
eclipse-plugin.build.properties
在文件中写入:eclipse.home=/path/to/eclipse
然后再执行ant package就会编译生成 eclipse插件了。
但事实上会报错。。。用官方网站上已经编译好的插件,版本又和主干对不上的。
自己在机器上跑了下,还是不用hadoop插件了,主要配置正确,启动个hadoop就可以了。
浏览 21295
浏览: 239069 次
来自: 火星
这个ibatis 还真是不好用啊。楼主解决了我看文档也没解决的 ...
SqlMapClientTemplate sqlMa ...
2楼肯定是people.xsd格式错了
遇到同样的问题,请教如何解决的java.io.NotSeria ...}

我要回帖

更多关于 hadoop源码分析 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信