//此处插入超链接
注意:所有操作必须在root用户下完成
JDK解压、配置环境变量 JAVA_HOME和PATH,验证java-version(如下都需要验证是否配置成功) [root@hadoop200 software] # tar -zxf jdk-8u261-linux-x64.tar.gz -C /opt/module/ [root@hadoop200 software]# vi /etc/profile #JAVA_HOME: export JAVA_HOME=/opt/module/jdk1.8.0_261 export PATH=$PATH:$JAVA_HOME/bin [root@hadoop200 software]#source /etc/profile验证命令:java -version
Maven解压、配置 MAVEN_HOME和PATH [root@hadoop200 software]# tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /opt/module/ [root@hadoop200 apache-maven-3.0.5]# vi conf/settings.xml <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors> [root@hadoop200 apache-maven-3.0.5]# vi /etc/profile #MAVEN_HOME export MAVEN_HOME=/opt/module/apache-maven-3.0.5 export PATH=$PATH:$MAVEN_HOME/bin [root@hadoop200 software]#source /etc/profile验证命令:mvn -version
ant解压、配置 ANT _HOME和PATH [root@hadoop200 software]# tar -zxvf apache-ant-1.9.9-bin.tar.gz -C /opt/module/ [root@hadoop200 apache-ant-1.9.9]# vi /etc/profile #ANT_HOME export ANT_HOME=/opt/module/apache-ant-1.9.9 export PATH=$PATH:$ANT_HOME/bin [root@hadoop200 software]#source /etc/profile验证命令:ant -version
安装 glibc-headers 和 g++ 命令如下: [root@hadoop200 apache-ant-1.9.9]# yum install glibc-headers [root@hadoop200 apache-ant-1.9.9]# yum install gcc-c++ 安装make和cmake [root@hadoop200 apache-ant-1.9.9]# yum install make [root@hadoop200 apache-ant-1.9.9]# yum install cmake 解压protobuf ,进入到解压后protobuf主目录,/opt/module/protobuf-2.5.0,然后相继执行命令 [root@hadoop200 software]# tar -zxvf protobuf-2.5.0.tar.gz -C /opt/module/ [root@hadoop200 opt]# cd /opt/module/protobuf-2.5.0/ [root@hadoop200 protobuf-2.5.0]#./configure [root@hadoop200 protobuf-2.5.0]# make [root@hadoop200 protobuf-2.5.0]# make check [root@hadoop200 protobuf-2.5.0]# make install [root@hadoop200 protobuf-2.5.0]# ldconfig [root@hadoop200 hadoop-dist]# vi /etc/profile #LD_LIBRARY_PATH export LD_LIBRARY_PATH=/opt/module/protobuf-2.5.0 export PATH=$PATH:$LD_LIBRARY_PATH [root@hadoop200 software]#source /etc/profile验证命令:protoc --version
安装openssl库 [root@hadoop200 software]#yum install openssl-devel 安装 ncurses-devel库 [root@hadoop200 software]#yum install ncurses-devel到此,编译工具安装基本完成。
等待时间30分钟左右,最终成功是全部SUCCESS:
成功的64位hadoop包在/opt/hadoop-2.7.2-src/hadoop-dist/target下 [root@hadoop200 target]# pwd /opt/hadoop-2.7.2-src/hadoop-dist/target 编译源码过程中常见的问题及解决方案 5.1 MAVEN install时候JVM内存溢出 处理方式:在环境配置文件和maven的执行文件均可调整MAVEN_OPT的heap大小。(详情查阅MAVEN 编译 JVM调优问题,如:http://outofmemory.cn/code-snippet/12652/maven-outofmemoryerror-method) 5.2 编译期间maven报错。可能网络阻塞问题导致依赖库下载不完整导致,多次执行命令(一次通过比较难): [root@hadoop200 hadoop-2.7.2-src]#mvn package -Pdist,nativeN -DskipTests -Dtar5.3 报ant、protobuf等错误,插件下载未完整或者插件版本问题,最开始链接有较多特殊情况,同时推荐 2.7.0版本的问题汇总帖子 http://www.tuicool.com/articles/IBn63qf