软件名称 | 版本 |
---|---|
Hadoop | 2.7.7 |
HBase | 1.2.9 |
jdk | 1.8.0 |
maven | 3.5.4 |
SNAPPY | 1.1.3 |
protobuf | 2.5.0 |
yum install -y automake autoconf gcc-c++ cmake libedit libtool openssl-devel ncurses-devel
2.2 安装maven
yum install wget -y
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
tar xvf apache-maven-3.5.4-bin.tar.gz -C /opt/
ln -s /opt/apache-maven-3.5.4 /opt/apps/maven
2.3 配置环境变量
vi /etc/profile
export MAVEN_HOME=/opt/apps/maven
export PATH=$PATH:$MAVEN_HOME/bin
#环境变量生效
source /etc/profile
3 安装SNAPPY
wget https://src.fedoraproject.org/repo/pkgs/snappy/snappy-1.1.3.tar.gz/7358c82f133dc77798e4c2062a749b73/snappy-1.1.3.tar.gz
tar xvf snappy-1.1.3.tar.gz -C /opt/
cd /opt/snappy-1.1.3
./configure
make
make install
#卸载命令 make uninstall
忽视如下打印信息,不造成影响
make[1]: Leaving directory `/opt/apps/snappy-1.1.3’
ll /usr/local/lib/ | grep snappy
如下所示安装成功wget http://sourceforge.net/projects/protobuf/files/protobuf-2.5.0.tar.gz/download -O protobuf-2.5.0.tar.gz
tar xvf protobuf-2.5.0.tar.gz -C /opt/
cd /opt/protobuf-2.5.0/
./autogen.sh
./configure
make
make install
忽视如下打印信息,不造成影响
make[1]: Leaving directory `/opt/apps/snappy-1.1.3’
protoc --version
5 Hadoop Snappy 源码编译
编译过程较长
编译之前先修改maven下载镜像vi /opt/apps/maven/conf/settings.xml
alimaven
aliyun maven
http://maven.aliyun.com/nexus/content/groups/public/
central
下载编译hadoop源码
wget http://archive.apache.org/dist/hadoop/core/hadoop-2.7.7/hadoop-2.7.7-src.tar.gz
tar xvf hadoop-2.7.7-src.tar.gz -C /opt/
cd /opt/hadoop-2.7.7-src
export MAVEN_OPTS="-Xms256m -Xmx512m"
mvn package -Pdist,native -DskipTests -Dtar -rf :hadoop-common -Drequire.snappy -X
#若重新编译
#mvn clean package -Pdist,native -DskipTests -Dtar -rf :hadoop-common -Drequire.snappy -X
查看编译结果
[root@hdc-data4 hadoop-2.7.2-src]# ls hadoop-dist/target/hadoop-2.7.2/lib/native/
libhadoop.a libhadooppipes.a libhadoop.so libhadoop.so.1.0.0 libhadooputils.a libhdfs.a libhdfs.so libhdfs.so.0.0.0
6 Hadoop 安装配置 Snappy
将编译结果 hadoop-dist/target/hadoop-2.7.7/lib/native/下的所有文件拷贝到hadoop安装目录下lib/native/
cp -r /opt/hadoop-2.7.7-src/hadoop-dist/target/hadoop-2.7.7/lib/native/* /opt/apps/hadoop/lib/native/
修改core-site.xml,添加
io.compression.codecs
org.apache.hadoop.io.compress.SnappyCodec
修改yarn-site.xml , 添加
mapreduce.map.output.compress
true
mapred.map.output.compress.codec
org.apache.hadoop.io.compress.SnappyCodec
将修改的配置同步到集群
scp -r /opt/apps/hadoop/lib/native/* root@hdc-data5:/opt/apps/hadoop/lib/native/
scp -r /opt/apps/hadoop/lib/native/* root@hdc-data6:/opt/apps/hadoop/lib/native/
scp -r /opt/apps/hadoop/etc/hadoop/core-site.xml root@hdc-data5:/opt/apps/hadoop/etc/hadoop/
scp -r /opt/apps/hadoop/etc/hadoop/core-site.xml root@hdc-data6:/opt/apps/hadoop/etc/hadoop/
scp -r /opt/apps/hadoop/etc/hadoop/yarn-site.xml root@hdc-data5:/opt/apps/hadoop/etc/hadoop/
scp -r /opt/apps/hadoop/etc/hadoop/yarn-site.xml root@hdc-data6:/opt/apps/hadoop/etc/hadoop/
验证
hadoop checknative -a
7 HBase 配置 Snappy
mkdir -p /opt/apps/hbase/lib/native/Linux-amd64-64
cp -r /opt/apps/hadoop/lib/native/* /opt/apps/hbase/lib/native/Linux-amd64-64/
修改 hbase-env.sh,添加
同步配置到HBASE集群
重启服务及测试
touch /tmp/a
hbase org.apache.hadoop.hbase.util.CompressionTest /tmp/a snappy
bin/hbase shell
create 'tsnappy',{ NAME => 'f', COMPRESSION => 'snappy'}