Windows Eclipse Hadoop 开发

来源:互联网 发布:node.js w3cschool 编辑:程序博客网 时间:2024/05/18 03:58

1. eclipse添加hadoop-eclipse-plugin插件

下载: hadoop2x-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


DFS

2. eclipse 设置Hadoop Map/Reduce Locations

Windows -> Preferences


hadoop map/reduce

Windows -> Perspective -> Open Perspective -> Other… 选中 Map/Reduce

map/reduce perspective

进入Map/Reduce视图,新建 Hadoop location…

Map/Reduce Location

设置集群地址

edit hadoop location

3. Windows 本地配置

下载64位的hadoop2.6版本插件,放在某一目录的bin目录下(一定要为bin目录)


bin

下载: hadoop2.6-x64

将其中的hadoop.dll 拷贝至 C:\Windows\System32目录下


system32

4. 工程配置

新建MapReduce工程


mapreduce project

将集群中hadoop-2.6.4/etc/hadoop下的配置文件拷贝到工程下

site file

利用hadoop-wiki例子:WordCount

测试:
代码添加设置系统属性”hadoop.home.dir”,value值为第三步设置bin目录的父目录。

System.setProperty("hadoop.home.dir", "D:\\hadoop\\hadoop2.6-x64" );

5. 常见错误

  1. 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上将其替换
0 0
原创粉丝点击