编译Windows版本的hadoop

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32782059/article/details/80590278
在Windows上构建和安装Hadoop 2.x及以上的版本。
hadoop建议在linux上运行,但是作为开发人员,一般大家使用的开发环境都是windows,因此构建windows版本的hadoop可以大大的方便MR的开发和测试。

一、介绍
Hadoop没有官方的Windows二进制版本,然而,从源代码构建windows版本是相当的容易。

二、构建Hadoop Core
2.1 选择OS版本。
Windows Server 2008 和 Windows Server 2008 R2 处于开发和测试中。Vista 和windows 7应该也是可以的。
不要使用Cygwin来运行。Cygwin不需要,也是不支持的。

2.2 选择JAVA版本,设置JAVA_HOME
jdk 1.7和1.6已经通过测试。
测试:java -version
2.3 获取Hadoop 源代码
本文下的是2.9.0版本。
2.4 安装依赖并设置构建环境
仔细阅读 源代码包中的 BUILDI NG.txt  
Windows上依赖的软件。
* Windows System
* JDK 1.8+
* Maven 3.3 or later
测试:mvn -version
* Findbugs 1.3.9 (if running findbugs)
这个可以不需要。
* ProtocolBuffer 2.5.0
备注:直接下载protoc-2.5.0-win32.zip,使用编译好的protoc.exe,并加入到path里面。

* CMake 2.6 or newer
* Windows SDK 7.1 or Visual Studio 2010 Professional
安装如下软件:
Visual Studio 2010
Visual Studio 2010 SP1
备注: 如果64位版本不能编译的话,还需要安装VC-Compiler-KB2519277.exe
* Windows SDK 8.1 (if building CPU rate control for the container executor)
这个可以不需要。
* zlib headers (if building native code bindings for zlib)
编译windows的版本
进入zlib源代码目录
mkdir install
cd install
cmake -G "Visual Studio 15 2017" -A x64 ../
cmake --build .
备注:上面的是编译出了Debug版本。
编译Release版本: MSBuild zlib.sln /t:Rebuild /p:Configuration=Release
需要拷贝出来的头文件(.h)
* Internet connection for first build (to fetch all Maven and Hadoop dependencies)
* Unix command-line tools from GnuWin32: sh, mkdir, rm, cp, tar, gzip. These
tools must be present on your PATH.
建议安装git, 将git/bin目录加入到path环境变量中。

* Python ( for generation of docs using 'mvn site')
* patch for windows.
解压到:C:\Java\patch-2.5.9

2.5 修改vs项目的预处理项。
WSCE_CONFIG_DIR=$(WsceConfigDir)
WSCE_CONFIG_FILE=$(WsceConfigFile)
备注: 参考附录部分。

2.6 开始编译。
在Linux上,Hadoop的Native API支持是可选的,但是在Windows平台上却是必须的。
确保根据building.txt正确构建本地IO的支持。
a 进入命令提示界面(以管理员身份运行)
b 依次运行如下命令
set Platform=x64
set ZLIB_HOME=C:\Java\zlib-1.2.7
set path=%path%;C:\Program Files\Git\bin;C:\Java\patch-2.5.9\bin
mvn package -Pdist,native-win -Pdocs -Dtar -DskipTests

// -Psrc 的选项不能要,会出错误。

附录A: libwinutils编译错误
原因是取不到值。:
WSCE_CONFIG_DIR=$(WsceConfigDir)
WSCE_CONFIG_FILE=$(WsceConfigFile)
项目的配置

根据hadoop-common\pom.xml里面的东西来修改。
<properties>
<hadoop.component>common</hadoop.component>
<is.hadoop.component>true</is.hadoop.component>
<is.hadoop.common.component>true</is.hadoop.common.component>
<wsce.config.dir>../etc/hadoop</wsce.config.dir>
<wsce.config.file>wsce-site.xml</wsce.config.file>
</properties>
然后再编译vs的项目就可以成功了。

附录B winutils连接错误:
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
备注
安装VS 2010 SP1即解决问题。

附录C hadoop-aws编译不通过的问题。
Could not find artifact com.amazonaws:DynamoDBLocal
放到本地仓库如下地址:
mavenrepo\com\amazonaws\DynamoDBLocal\1.11.86


猜你喜欢

转载自blog.csdn.net/qq_32782059/article/details/80590278
今日推荐