一、安装编译相关依赖
此篇文档及Hadoop相关文档相关软件包统一在此百度网盘:
链接:https://pan.baidu.com/s/11F4THdIfgrULMn2gNcObRA?pwd=cjll
yum install snappy snappy-devel bzip2 bzip2-devel lzo lzo-devel lzop libXtst lzo-devel zlib-devel openssl openssl-devel ncurses-devel autoconf automake libtool curl gcc gcc-c++ make
yum install cmake # cmake版本需要3.6,如果epel源版本不够,下面有手动编译步骤
mkdir -p /export/server # 编译环境软件安装目录
手动编译cmake
#yum卸载已安装cmake 版本低
yum erase cmake
#解压
tar zxvf cmake-3.13.5.tar.gz
#编译安装
cd /export/server/cmake-3.13.5
./configure
make && make install
#验证
[root@node4 ~]# cmake -version
cmake version 3.13.5
#如果没有正确显示版本 请断开SSH连接 重写登录
手动编译snappy
#卸载已经安装的
cd /usr/local/lib
rm -rf libsnappy*
#上传解压
tar zxvf snappy-1.1.3.tar.gz
#编译安装
cd /export/server/snappy-1.1.3
./configure
make && make install
#验证是否安装
[root@node1 snappy-1.1.3]# ls -lh /usr/local/lib |grep snappy
-rw-r--r-- 1 root root 511K Nov 4 17:13 libsnappy.a
-rwxr-xr-x 1 root root 955 Nov 4 17:13 libsnappy.la
lrwxrwxrwx 1 root root 18 Nov 4 17:13 libsnappy.so -> libsnappy.so.1.3.0
lrwxrwxrwx 1 root root 18 Nov 4 17:13 libsnappy.so.1 -> libsnappy.so.1.3.0
-rwxr-xr-x 1 root root 253K Nov 4 17:13 libsnappy.so.1.3.0
二、编译环境准备
1.安装配置JDK 1.8
#解压安装包
tar zxvf jdk-8u65-linux-x64.tar.gz
#配置环境变量
vim /etc/profile
export JAVA_HOME=/export/server/jdk1.8.0_65
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
#验证是否安装成功
java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
You have new mail in /var/spool/mail/root
2.安装配置maven
#解压安装包
tar zxvf apache-maven-3.5.4-bin.tar.gz
#配置环境变量
vim /etc/profile
export MAVEN_HOME=/export/server/apache-maven-3.5.4
export MAVEN_OPTS="-Xms4096m -Xmx4096m"
export PATH=:$MAVEN_HOME/bin:$PATH
source /etc/profile
#验证是否安装成功
[root@node4 ~]# mvn -v
Apache Maven 3.5.4
#添加maven 阿里云仓库地址 加快国内编译速度
vim /export/server/apache-maven-3.5.4/conf/settings.xml
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
3.安装ProtocolBuffer 2.5.0
#解压
tar zxvf protobuf-2.5.0.tar.gz
#编译安装
cd /export/server/protobuf-2.5.0
./configure
make && make install
#验证是否安装成功
[root@node4 protobuf-2.5.0]# protoc --version
libprotoc 2.5.0
三、编译Hadoop
#上传解压源码包
tar zxvf hadoop-3.1.4-src.tar.gz
#编译
cd /export/server/hadoop-3.1.4-src
mvn clean package -Pdist,native -DskipTests -Dtar -Dbundle.snappy -Dsnappy.lib=/usr/local/lib
#参数说明:
Pdist,native :把重新编译生成的hadoop动态库;
DskipTests :跳过测试
Dtar :最后把文件以tar打包
Dbundle.snappy :添加snappy压缩支持【默认官网下载的是不支持的】
Dsnappy.lib=/usr/local/lib :指snappy在编译机器上安装后的库路径
编译之后的安装包路径
/export/server/hadoop-3.1.4-src/hadoop-dist/target
"一劳永逸" 的话,有是有的,而 "一劳永逸" 的事却极少