1、下载源码,通过编译源码安装
tar -zxvf /home/zfll/soft/snappy-1.1.2.tar.gz
cd snappy-1.1.2
./configure
make
sudo make install(输入root的密码)
2、安装hadoop-snappy包
解压 unzip /home/zfll/soft/hadoop-snappy-master.zip
编译 cd hadoop-snappy-master/
mvn clean package -Dmaven.test.skip=true
编译后把本地库文件和jar包(编译后可能已经打在一个压缩包里,需要先解压)拷贝到相应的目录
cd /home/zfll/hadoop-snappy-master/target
tar -zxvf hadoop-snappy-0.0.1-SNAPSHOT.tar.gz
cp -r hadoop-snappy-0.0.1-SNAPSHOT/lib/* $HADOOP_HOME/lib
cp hadoop-snappy-0.0.1-SNAPSHOT.jar $HADOOP_HOME/lib
Snappy 0.0.1-SNAPSHOT/目录包含本地库和hadoop-snappy-0.0.1-SNAPSHOT.jar包,都需要拷贝到相应的目录。
3、配置hadoop-env.sh 添加:
cd /home/zfll/hadoop/etc/hadoop
vi hadoop-env.sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HADOOP_HOME/lib/native/Linux-amd64-64/:/usr/local/lib/
4、配置mapred-site.xml 增加
cd /home/zfll/hadoop/etc/hadoop
vi mapred-site.xml
<property> <name>mapred.compress.map.output</name> <value>true</value> </property> <property> <name>mapred.map.output.compression.codec</name> <value>org.apache.hadoop.io.compress.SnappyCodec</value> </property>
vi core-site.xml
<property> <name>io.compression.codecs</name> <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.BZip2Codec,org.apache.hadoop.io.compress.SnappyCodec</value> </property>
注意以上文件,每个节点都要修改增加
6、Hbase配置Snappy
1)、cd /home/zfll/hbase/lib
mkdir -p native/Linux-amd64-64
cp -r $HADOOP_HOME/lib/native/Linux-amd64-64/* $HBASE_HOME/lib/native/Linux-amd64-64/
2)、配置hbase环境变量
cd /home/zfll/hbase/conf
vi hbase-env.sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HADOOP_HOME/lib/native/Linux-amd64-64/:/usr/local/lib/
export HBASE_LIBRARY_PATH=$HBASE_LIBRARY_PATH :$HBASE_HOME/lib/native/Linux-amd64-64/:/usr/local/lib/
vi hbase-site.xml 保证启动以snappy方式启动
<property> <name>hbase.regionserver.codecs</name> <value>snappy</value> </property>
3)、重启hadoop和hbase
在server1-hadoop-namenode-01上stop-dfs.sh stop-yarn.sh
stop-hbase.sh
start-dfs.sh start-yarn.sh
hbase-daemon.sh start master
在server2-hadoop-namenode-02上启动备用进程:
yarn-daemon.sh stop resourcemanager
yarn-daemon.sh start resourcemanager
hbase-daemon.sh start master
在安装hbase接点上分别启动hbase的regionserver
hbase-daemon.sh start regionserver
4)、验证Hbase配置是否成功(在server1-hadoop-namenode-01上操作)
接下来创建并操作Snappy压缩格式的表
1、hbase shell
2、create ‘tsnappy’, { NAME => ‘f’, COMPRESSION => ‘snappy’}
3、describe ‘tsnappy’
4、put ‘tsnappy’, ‘row1’, ‘f:col1’, ‘value’
5、scan ‘tsnappy’
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/9054.html