HBase在CentOS上的压缩算法选择指南
一、算法对比与快速推荐
二、在CentOS上的部署与启用步骤
hbase org.apache.hadoop.util.NativeLibraryCheckerhbase org.apache.hadoop.hbase.util.CompressionTest /tmp/testfile snappycreate 't', 'cf', {NAME => 'cf', COMPRESSION => 'SNAPPY'}
TableDescriptor td = TableDescriptorBuilder.newBuilder(TableName.valueOf("t"))
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("cf"))
.setCompressionType(Compression.Algorithm.SNAPPY).build())
.build();
admin.createTable(td);
alter 't', {NAME => 'cf', COMPRESSION => 'LZ4'}
TableDescriptor td = admin.getDescriptor(TableName.valueOf("t"));
ColumnFamilyDescriptor cfd = td.getColumnFamily(Bytes.toBytes("cf"))
.toBuilder().setCompressionType(Compression.Algorithm.LZ4).build();
admin.modifyColumnFamily(TableName.valueOf("t"), cfd);
hbase-site.xml中配置默认压缩(示例):<property>
<name>hbase.hstore.defaultengine.compression</name>
<value>snappy</value>
</property>
describe 't'(应看到Compression为设定值)hbase org.apache.hadoop.hbase.io.hfile.HFile -f /hbase/data/default/t/cf/... -m三、参数调优与组合策略
四、常见问题与排查要点
NativeLibraryChecker与CompressionTest定位缺失库;确认Hadoop Native与HBase Native库已安装且版本匹配;必要时在hbase-site.xml中显式声明可用编解码器列表(如:hbase.regionserver.codecs=lz4,snappy,zstd)。HFile工具复核压缩比。