1.下载maven(apache-maven-3.3.3-bin.tar.gz)
wget http://archive.apache.org/dist/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
2.安装maven
tar -zxvf apache-maven-3.3.3-bin.tar.gz -C /usr/local/src/
mv apache-maven-3.3.3-bin maven
3.下载protobuf(https://code.google.com/p/protobuf/downloads/list 或 https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz)
4.安装protobuf编译依赖,为了编译安装protoc,需要使用YUM下载几个依赖的工具
yum install -y gcc gcc-c++ make cmake
5.解压安装protobuf
tar -zxvf protobuf-2.5.0.tar.gz -C /usr/local/src
cd /usr/local/src/protobuf-2.5.0
./configure --prefix=/usr/local/protobuf
make && make install
6.下载findbugs
wget --no-check-certificate https://sourceforge.net/projects/findbugs/files/findbugs/1.3.9/findbugs-1.3.9.tar.gz/download -O findbugs-1.3.9.tar.gz
7.安装findbugs
解压 配置环境变量
执行以下命令,校验是否安装成功
findbugs -version
8.安装其它编译依赖
yum install -y cmake openssl-devel ncurses-devel zlib-devel
yum install -y snappy snappy-devel bzip2 bzip2-devel lzo lzo-devel lzop openssl openssl-devel
9.在编译过程中为了防止Java内存溢出,需要加入以下环境变量 jdk1.8已经移除该配置
export MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=512m"
10.配置环境变量
JAVA_HOME=/usr/local/src/java/jdk1.8.0_73
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
MAVEN_HOME=/usr/local/src/maven
SCALA_HOME=/usr/local/src/scala
PROTOBUF_HOME=/usr/local/src/protobuf
FINDBUGS_HOME=/usr/local/src/findbugs-1.3.9
MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=512m"
PATH=$PATH:$JAVA_HOME/bin:$CLASSPATH:$MAVEN_HOME/bin:$SCALA_HOME/bin:$PROTOBUF_HOME/bin:$FINDBUGS_HOME/bin:$MAVEN_OPTS
export PATH JAVA_HOME CLASSPATH SCALA_HOME MAVEN_HOME PROTOBUF_HOME FINDBUGS_HOME MAVEN_OPTS
11.编译hadoop(进入文件夹里面,里面有一个文件BUILDINT.txt,打开即可看见里面关于编译hadoop的一些环境要求)
tar -zxvf hadoop-2.7.3-src.tar.gz -C /usr/local/src/
cd /usr/local/src/hadoop-2.6.4-src
mvn clean package -Pdist,native -DskipTests -Dtar
12.查看编译好的安装包
cd /usr/local/src/hadoop-2.6.4-src/hadoop-dist/target
出现问题
INFO util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
在/etc/profile中添加
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
查看可用的本地库
hadoop checknative -a
cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc –l
cat /proc/cpuinfo | grep "core id" | sort -u | wc -l
cat /proc/cpuinfo | grep MHz | uniq