通过hadoop源码编译,安装snappy并生成hadoop native本地库。
编译步骤:
1、安装maven
tar -zxvf
apache-maven-3.3.3-bin.tar.gz//解压
mv apache-maven-3.3.3
maven//修改名称
vi /etc/profile//添加环境变量
MAVEN_HOME=/usr/java/maven
PATH=$MAVEN_HOME/bin:$PATH
exportMAVEN_HOME
保存退出
source /etc/profile//使文件生效
mvn–v//查看maven版本
2、安装ProtocolBuffer
tar -zxvfprotobuf-2.5.0.tar.gz
mv protobuf-2.5.0 protobuf
cd protobuf
./configure --prefix=/usr/local/protobuf
make
make check
make install
vi /etc/profile//添加环境变量
PROTOBUF_HOME=/usr/local/protobuf
PATH=$PROTOBUF_HOME/bin:$PATH
exportPROTOBUF_HOME
保存退出
source /etc/profile//使文件生效
protoc–version查看版本号
3、安装cmake
yum -y install cmake
4、zlib安装
yum -y install zlib
5、安装openssl-devel
yum -y install openssl-devel
6、安装snappy
tar -zxvf snappy-1.1.3.tar.gz
mv snappy-1.1.3 snappy
cd snappy
./configure
make
make install
7、编译hadoop源码hadoop-2.2.0-src
tar–zxvf hadoop-2.2.0-src.tar.gz
cd hadoop-2.2.0-src
mvn package -Pdist,native -DskipTests -Dtar -Dbundle.snappy-Dsnappy.lib=/usr/local/lib
8、编译完成后把编译好的hadoop解压提取native本地库替换现有机器上装的hadoop的native
9、Hadoop配置snappy压缩
配置hadoop-env.sh
exportHADOOP_HOME=/usr/java/hadoop安装目录
exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HADOOP_HOME/lib/native
配置core-site.xml
io.compression.codecs
org.apache.hadoop.io.compress.SnappyCodec
配置mapred-site.xml
如果MR中间结果需要使用snappy压缩,修改mapred-site.xml
mapreduce.map.output.compress
true
mapreduce.map.output.compress.codec
org.apache.hadoop.io.compress.SnappyCodec