本文共 6423 字,大约阅读时间需要 21 分钟。
Windows10下安装Hadoop2.6,Windows10下编译64位Hadoop2.x。详细记录了Windows10版本下对Hadoop的编译、安装步骤,以及相关包或者软件下载安装过程。
不需要在Cygwin下安装Hadoop,官方也不推荐使用Cygwin。
Hadoop版本支持情况:Hadoop 2.2版本起包括Windows的原生支持。截至2014年一月份,官方的Apache Hadoop的版本不包括Windows二进制文件。
Windows版本支持情况:Hadoop官方人员开发、测试环境分别是32的 Windows Server 2008 和32位的 Windows Server 2008 R2 。因为服务器型号win32位的API相似,所以官方推测Windows7或者Windows Vista应该也是支持的。Windows XP Hadoop官方不测试也不支持。
总之,Windows版本的Hadoop需要在2.2之后可自行编译,并且不支持Windows XP,在其他Windows平台下,官方不予严格的支持(仅仅提供二进制文件,部分组件需要自行编译)。
以下内容是具体实施,Hadoop集群在Windows环境下支持情况调研与测试部署,罗列了Windows实际部署情况,以及所遇到的问题和解决方案。
* Windows System* JDK 1.6+* Maven 3.0 or later* Findbugs 1.3.9 (if running findbugs)* ProtocolBuffer 2.5.0* CMake 2.6 or newer* Windows SDK or Visual Studio 2010 Professional* Unix command-line tools from GnuWin32 or Cygwin: sh, mkdir, rm, cp, tar, gzip* zlib headers (if building native code bindings for zlib)* Internet connection for first build (to fetch all Maven and Hadoop dependencies)
JAVA_HOME设置
jdk设置path
下载maven的zip包 将maven的根目录放置系统变量path中
测试mvn -v
下载 先切换到带有pom文件路径中
cd E:\IDE\protobuf-3.0.0-beta-3\java
通过mvn 安装 mvn test 测试 mvn install
下载 安装即可。
设置环境编译环境位数 set Platform=x64 (when building on a 64-bit system) set Platform=Win32 (when building on a 32-bit system) 设置安装包环境 设置环境变量添加至将ZLIB_HOME至环境变量中 set ZLIB_HOME=C:\zlib-1.2.7 mvn编译命令
mvn package -Pdist,native-win -DskipTests -Dtar
core-site.xml 源码
fs.default.name hdfs://0.0.0.0:19000
Hadoop-env.cmd 源码
set HADOOP_PREFIX=E:\bigdata\hadoopset HADOOP_CONF_DIR=%HADOOP_PREFIX%\etc\hadoopset YARN_CONF_DIR=%HADOOP_CONF_DIR%set PATH=%PATH%;%HADOOP_PREFIX%\bin
hdfs-site.xml 源码
dfs.replication 1
mapre-site.xml 源码
mapreduce.job.user.name wxl mapreduce.framework.name yarn yarn.apps.stagingDir /user/wxl/staging mapreduce.jobtracker.address local
yarn-site.xml 源码
yarn.server.resourcemanager.address 0.0.0.0:8020 yarn.server.resourcemanager.application.expiry.interval 60000 yarn.server.nodemanager.address 0.0.0.0:45454 yarn.nodemanager.aux-services mapreduce_shuffle yarn.nodemanager.aux-services.mapreduce.shuffle.class org.apache.hadoop.mapred.ShuffleHandler yarn.server.nodemanager.remote-app-log-dir /app-logs yarn.nodemanager.log-dirs /dep/logs/userlogs yarn.server.mapreduce-appmanager.attempt-listener.bindAddress 0.0.0.0 yarn.server.mapreduce-appmanager.client-service.bindAddress 0.0.0.0 yarn.log-aggregation-enable true yarn.log-aggregation.retain-seconds -1 yarn.application.classpath %HADOOP_CONF_DIR%,%HADOOP_COMMON_HOME%/share/hadoop/common/*,%HADOOP_COMMON_HOME%/share/hadoop/common/lib/*,%HADOOP_HDFS_HOME%/share/hadoop/hdfs/*,%HADOOP_HDFS_HOME%/share/hadoop/hdfs/lib/*,%HADOOP_MAPRED_HOME%/share/hadoop/mapreduce/*,%HADOOP_MAPRED_HOME%/share/hadoop/mapreduce/lib/*,%HADOOP_YARN_HOME%/share/hadoop/yarn/*,%HADOOP_YARN_HOME%/share/hadoop/yarn/lib/*
slaves 源码
localhost
E:\bigdata\hadoop\etc\hadoop\hadoop-env.cmd
%HADOOP_PREFIX%\bin\hdfs namenode -format
![successfully formatted](../Imgs/HadoopforWindows/successfully formatted.png)
%HADOOP_PREFIX%\sbin\start-dfs.cmd
会弹出两个cmd窗口,分别是datanode和namenode。 查看是否启动成功,在原先窗口输入jps查看,如图。
%HADOOP_PREFIX%\bin\hdfs dfs -put myfile.txt /
%HADOOP_PREFIX%\bin\hdfs dfs -ls /
%HADOOP_PREFIX%\sbin\start-yarn.cmd
输入jps命令可查看当前启动的节点,如图
%HADOOP_PREFIX%\bin\yarn jar %HADOOP_PREFIX%\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.6.4.jar wordcount /myfile.txt /out
%HADOOP_PREFIX%\sbin\stop-yarn.cmd%HADOOP_PREFIX%\sbin\stop-dfs.cmd
mvn package -Pdist,native-win -DskipTests -Dtar
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (pre-dist) on project hadoop-project-dist: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program “sh” (in directory “E:\bigdata\hadoop\hadoop-project-dist\target”): CreateProcess error=2, 系统找不到指定的文件。
org.apache.hadoop.io.nativeio.NativeIOWindows.acce![org.apache.hadoop.io.nativeio.NativeIOWindows.access0](../Imgs/HadoopforWindows/log_org.apache.hadoop.io.nativeio.NativeIO$Windows.access0.png)
解决: 下载Hadoop2.6.4 bin编译的包,并且复制到Hadoop目录的bin目录下。![ org.apache.hadoop.io.nativeio.NativeIO$Windows.access0](../Imgs/HadoopforWindows/log_org解决apache.hadoop.io.nativeio.NativeIO$Windows.access0.png)
Application application_1467703817455_0002 failed 2 times due to AM Container for appattempt_1467703817455_0002_000002 exited with exitCode: -1000 For more detailed output, check application tracking page:, click on links to logs of each attempt. Diagnostics: Failed to setup local dir /tmp/hadoop-wxl/nm-local-dir, which was marked as good. Failing this attempt. Failing the application.
log_Failed while trying to construct the redirect url to the log server.png 解决方案:权限问题解决: