1 概述
本文主要简单描述下搭建hadoop3.3.0源码阅读环境的搭建过程。
在搭建时可以先阅读下源码中的 building.txt文件,主要各个依赖的版本参见如下:
Requirements: * Unix System * JDK 1.8 * Maven 3.3 or later * Protocol Buffers 3.7.1 (if compiling native code) * CMake 3.1 or newer (if compiling native code) * Zlib devel (if compiling native code) * Cyrus SASL devel (if compiling native code) * One of the compilers that support thread_local storage: GCC 4.8.1 or later, Visual Studio, Clang (community version), Clang (version for iOS 9 and later) (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) * Doxygen ( if compiling libhdfspp and generating the documents ) * Internet connection for first build (to fetch all Maven and Hadoop dependencies) * python (for releasedocs) * bats (for shell code testing) * Node.js / bower / Ember-cli (for YARN UI v2 building)
本文所用为虚拟机,centos7.9版本。
2 搭建过程
2.1 java 1.8安装
略。
2.2 maven3.8.4安装
略,配置mirror为阿里云。
2.3 安装依赖包
# 建议使用此顺序,否则可能出现依赖问题
yum install -y gcc gcc-c++
yum install -y make
yum install -y autoconf automake libtool curl
yum install -y lzo-devel zlib-devel openssl openssl-devel ncurses-devel
yum install -y snappy snappy-devel bzip2 bzip2-devel lzo lzo-devel lzop libXtst
2.4 protobuf安装
2.4.1 3.7.1版
需要手动编译安装
下载地址,下载protobuf-all-3.7.1.tar.gz
- 下载之后上传解压
- 进入protobuf包
- 执行编译
mkdir -p /usr/local/protobuf # 进入解压目录 ./configure --prefix=/usr/local/protobuf
- 执行安装
sudo make sudo make check #检测完成之后使用echo $?验证,返回0则表示成功 sudo make install
- 让动态链接库为系统所共享
ldconfig
- 测试是否可用
/usr/local/protobuf/bin/protoc --version
- 配置protobuf的/etc/profile配置
vim /etc/profile export PROTOBUF_HOME=/usr/local/protobuf/ export PATH=$PATH:$PROTOBUF_HOME/bin # 而后执行 source /etc/profile
2.4.2 2.5.0版
也可以使用linux提供的安装包使用2.5版,也能编译成功
yum install -y protobuf-devel.x86_64
2.5 安装cmake
直接下载对应版本即可,这里安装cmake-3.19.4
# 解压 tar -xvf cmake-3.19.4-Linux-x86_64.tar.gz -C /opt/ # 而后构建链接 ln -s /opt/cmake-3.19.4-Linux-x86_64/bin/cmake /usr/bin/cmake
2.6 安装snappy
下载snappy-1.1.3版:Index of /repo/pkgs/snappy
#上传解压 tar zxvf snappy-1.1.3.tar.gz #编译安装 cd /export/server/snappy-1.1.3 ./configure make && make install #验证是否安装 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



