centOS7上編譯hadoop-2.7.7

1、閱讀編譯文檔

在hadoop源碼包根目錄下有個一個BUINDING.txt的文件,文件說明了編譯hadoop所須要的一些編譯hadoop所須要的一些編譯環境相關的東西。不一樣hadoop版本的要求都不同。我選擇的版本是hadoop-2.7.7java

----------------------------------------------------------------------------------
Requirements:

* Unix 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 (if compiling native code), must be 3.0 or newer on Mac
* Zlib devel (if compiling native code)
* openssl devel ( if compiling native hadoop-pipes and to get the best HDFS encryption performance )
* Linux FUSE (Filesystem in Userspace) version 2.6 or above ( if compiling fuse_dfs )
* Internet connection for first build (to fetch all Maven and Hadoop dependencies)

2、軟件安裝

對應以上需求,準備好所要求版本的這些軟件。node

固然,以上所需的軟件我已經所有準備好了,😶連接:https://pan.baidu.com/s/1Fj-od3HpWQMI0IhvmTUdfQ 提取碼:68j6python

3、安裝JDK

選擇版本:jdk1.8.0_201linux

卸載系統自帶的openjdkc++

[root@localhost ~]# rpm -qa |grep java
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64
tzdata-java-2018c-1.el7.noarch
java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64
java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.2.el7.x86_64

忽略依賴卸載查詢到的openjdk相關包apache

rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64
...

上傳本身的jdk解壓,並配置環境變量centos

tar -zxvf jdk-8u201-linux-x64.tar.gz -C /opt/

打開/etc/profile文件添加如下內容app

export JAVA_HOME=/opt/jdk1.8.0_201
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

檢測是否安裝成功less

[root@localhost jdk1.8.0_201]# source /etc/profile
[root@localhost jdk1.8.0_201]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

4、安裝依賴包

根據編譯指導文件BUILDING.txt,安裝相關依賴程序包maven

[root@localhost jdk1.8.0_201]# yum -y install gcc-c++ build-essential autoconf automake libtool cmake zlib1g-dev pkg-config libssl-devua svn openssl-devel ncurses-devel

出現這種狀況時須要更換yum源,具體如何更換就很少說了,自行百度。

已加載插件:fastestmirror, langpacks
Loading mirror seeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.cn99.com
 * updates: mirrors.nwsuaf.edu.cn
沒有可用軟件包 build-essential。
沒有可用軟件包 zlib1g-dev。
沒有可用軟件包 pkg-config。
沒有可用軟件包 libssl-devua。
已安裝:
  autoconf.noarch 0:2.69-11.el7      automake.noarch 0:1.13.4-3.el7   cmake.x86_64 0:2.8.12.2-2.el7     
  gcc-c++.x86_64 0:4.8.5-36.el7_6.1  libtool.x86_64 0:2.4.2-22.el7_3  subversion.x86_64 0:1.7.14-14.el7 

做爲依賴被安裝:
  apr.x86_64 0:1.4.8-3.el7_4.1                          apr-util.x86_64 0:1.5.2-6.el7                     
  libstdc++-devel.x86_64 0:4.8.5-36.el7_6.1             m4.x86_64 0:1.4.16-10.el7                         
  perl-Data-Dumper.x86_64 0:2.145-3.el7                 perl-Test-Harness.noarch 0:3.28-3.el7             
  perl-Thread-Queue.noarch 0:3.02-2.el7                 subversion-libs.x86_64 0:1.7.14-14.el7            

做爲依賴被升級:
  libstdc++.x86_64 0:4.8.5-36.el7_6.1

5、安裝Maven

編譯要求:Maven 3.0 or later

安裝軟件:apache-maven-3.5.4-bin.tar

[root@localhost apps]# ls
apache-maven-3.5.4-bin.tar
[root@localhost apps]# tar -xvf apache-maven-3.5.4-bin.tar -C /opt

配置mvn的環境變量

export M2_HOME=/opt/apache-maven-3.5.4
export PATH=$PATH:$M2_HOME/bin

測試是否安裝完成

[root@localhost opt]# source /etc/profile
[root@localhost opt]# mvn -v
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
Maven home: /opt/apache-maven-3.5.4
Java version: 18.0_201, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_201/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.el7.x86_64", arch: "amd64", family: "unix"

6、安裝Findbugs

編譯要求:Findbugs 1.3.9
安裝軟件:findbugs-3.0.1.tar

[root@localhost apps]# ls
findbugs-3.0.1.tar
[root@localhost apps]# tar -xvf findbugs-3.0.1.tar -C /opt

配置Findbugs環境變量

export FINDBUGS_HOME=/opt/findbugs-3.0.1
export PATH=$PATH:$FINDBUGS_HOME/bin

測試是否安裝完成

[root@localhost apps]# source /etc/profile
[root@localhost apps]# findbugs -version
3.0.1

7、安裝ProtocolBuffer

編譯要求:ProtocolBuffer 2.5.0
安裝軟件:protobuf-2.5.0.tar,不建議用其它版本

[root@localhost apps]# ls
protobuf-2.5.0.tar
[root@localhost apps]# tar -zxvf protobuf-2.5.0.tar.gz -C /opt
[root@localhost apps]# cd /opt/protobuf-2.5.0/
[root@localhost protobuf-2.5.0]# ./configure 
[root@localhost protobuf-2.5.0]# make -j 4  # 乾貨,-j以4核同時編譯
[root@localhost protobuf-2.5.0]# make install

測試是否安裝完成

[root@localhost protobuf-2.5.0]# protoc --version
libprotoc 2.5.0

8、安裝Snappy

[root@localhost apps]# ls
snappy-1.1.3.tar.gz

安裝

[root@localhost opt]# cd snappy-1.1.3/
[root@localhost snappy-1.1.3]# ./configure
[root@localhost snappy-1.1.3]# make -j 4
[root@localhost snappy-1.1.3]# make install

查看snappy文件庫

[root@localhost snappy-1.1.3]# ls -lh /usr/local/lib | grep snappy
-rw-r--r--. 1 root root 510K 4月  12 14:14 libsnappy.a
-rwxr-xr-x. 1 root root  955 4月  12 14:14 libsnappy.la
lrwxrwxrwx. 1 root root   18 4月  12 14:14 libsnappy.so -> libsnappy.so.1.3.0
lrwxrwxrwx. 1 root root   18 4月  12 14:14 libsnappy.so.1 -> libsnappy.so.1.3.0
-rwxr-xr-x. 1 root root 253K 4月  12 14:14 libsnappy.so.1.3.0
[root@localhost snappy-1.1.3]#

9、開始編譯hadoop

[root@localhost apps]# ls
hadoop-2.7.7-src

在編譯以前防止java.lang.OutOfMemoryError:Java heap space堆棧問題,在centos系統執行

[root@hadoop1 snappy-1.1.3]# export MAVEN_OPTS="-Xms256m -Xmx512m"

進入源碼包下,執行命令進行編譯

[root@localhost snappy-1.1.3]# cd /root/apps/hadoop-2.7.7-src/
[root@localhost hadoop-2.7.7-src]# mvn package -Pdist,native,docs -DskipTests -Dtar

若是中途編譯失敗,而且不要文檔的話,請使用這個命令

[root@localhost hadoop-2.7.7-src]# mvn clear package -Pdist,native -DskipTests -Dtar -Dsnappy.lib=/usr/local/lib -Dbundle.snappy -Drequire.openssl

編譯成功後hadoop-2.7.7.tar.gz在hadoop-2.7.7-src/hadoop-dist/target目錄下

[root@node-1 target]# ls
antrun                    hadoop-2.7.7.tar.gz                 javadoc-bundle-options
classes                   hadoop-dist-2.7.7.jar               maven-archiver
dist-layout-stitching.sh  hadoop-dist-2.7.7-javadoc.jar       maven-shared-archive-resources
dist-tar-stitching.sh     hadoop-dist-2.7.7-sources.jar       test-classes
hadoop-2.7.7              hadoop-dist-2.7.7-test-sources.jar  test-dir
相關文章
相關標籤/搜索