Window下编译Hadoop
hadoop原码下载及解压
由于一直都在用2.8.5,所以这里以此版本为例,下载地址:
http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.8.5/
将下载后的原码解压至一个比较简洁的路径.如E:\hadoop\hdc
解压后我们手动将目录改个简短名字我这里叫
hdc如下:
然后打开BUILDING.txt文件,上面有具体编译的流程,下面附上一部分.
Building on Windows
----------------------------------------------------------------------------------
Requirements:
* Windows System
* JDK 1.7+
* Maven 3.0 or later
* Findbugs 1.3.9 (if running findbugs)
* ProtocolBuffer 2.5.0
* CMake 2.6 or newer
* Windows SDK 7.1 or Visual Studio 2010 Professional
* Windows SDK 8.1 (if building CPU rate control for the container executor)
* zlib headers (if building native code bindings for zlib)
* 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.
* Python ( for generation of docs using 'mvn site')
Unix command-line tools are also included with the Windows Git package which
can be downloaded from http://git-scm.com/downloads
If using Visual Studio, it must be Visual Studio 2010 Professional (not 2012).
Do not use Visual Studio Express. It does not support compiling for 64-bit,
which is problematic if running a 64-bit system. The Windows SDK 7.1 is free to
download here:
http://www.microsoft.com/en-us/download/details.aspx?id=8279
The Windows SDK 8.1 is available to download at:
http://msdn.microsoft.com/en-us/windows/bg162891.aspx
Cygwin is neither required nor supported.
值得注意的是,编译时Cygwin
已经不再被需要,也不再被支持了.
根据文档,下载并配置需要的内容:
1.JDK
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载后安装到默认目录即可,或者安装到自己喜欢的位置.
接下来,设置系统环境变量
# 以管理员权限运行cmd,然后执行下面的命令
jdk默认的安装路径是,C:\Program Files\Java\jdk1.8.0_231,但是文档中要求,JAVA_HOME目录不能有空格,
所以可以使用C:\PROGRA~1来代替C:\Program Files
JAVA_HOME must be set, and the path must not contain spaces. If the full path would contain spaces, then use the Windows short path instead.
setx /M JAVA_HOME "C:\PROGRA~1\Java\jdk1.8.0_231"
setx /M Path "%Path%;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin"
2.Maven
http://maven.apache.org/download.cgi