1. eclipse添加hadoop-eclipse-plugin插件
hadoop-2.5.2和hadoop-2.6.4版本选择hadoop-eclipse-plugin-2.6.0.jar(亲测可用)
将hadoop-eclipse-plugin-2.6.0.jar拷贝到eclipse\plugins下
重启eclipse
eclipse.exe -clean
这时,在eclipse Project Explorer视图下,能看到,多出了DFS Locations
2. eclipse 设置Hadoop Map/Reduce Locations
Windows -> Preferences
Windows -> Perspective -> Open Perspective -> Other… 选中 Map/Reduce
进入Map/Reduce视图,新建 Hadoop location…
设置集群地址
3. Windows 本地配置
下载64位的hadoop2.6版本插件,放在某一目录的bin目录下(一定要为bin目录)
下载: hadoop2.6-x64
将其中的hadoop.dll 拷贝至 C:\Windows\System32目录下
4. 工程配置
新建MapReduce工程
将集群中hadoop-2.6.4/etc/hadoop下的配置文件拷贝到工程下
利用hadoop-wiki例子: WordCount
测试:
代码添加设置系统属性”hadoop.home.dir”,value值为第三步设置bin目录的父目录。
System.setProperty("hadoop.home.dir", "D:\\hadoop\\hadoop2.6-x64" );
5. 常见错误
- Exceptionin thread “main” java.lang.UnsatisfiedLinkError:org.apache.hadoop.util.NativeCrc32.nativeComputeChunkedSumsByteArray(II[BI[BIILjava/lang/String;JZ)V
这是hadoop.dll 版本问题,2.4之前的版本和之后的使用hadoop.dll不一样
解决:需要选择正确的版本并且在 hadoop\bin和 C:\windows\system32上将其替换