解决HBase空间占用过大问题
问题现状:HBase中存储的数据不是很大,但是占用空间巨大
如下图可见HBase表中有几个占用空间未几十G
解决方式:修改HBase表的压缩算法
查看表压缩参数信息
通过desc命令可以查看到表的压缩算法COMPRESSION为NONE,这个是导致数据占用空间大的直接原因
hbase(main):011:0* desc 'linkcdc:cdc_con_tag'
Table linkcdc:cdc_con_tag is ENABLED
linkcdc:cdc_con_tag
COLUMN FAMILIES DESCRIPTION
{NAME => 'con_tag', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKC
ACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
1 row(s) in 0.0080 seconds
修改HBase表的压缩算法
切记:首先需要disable表,修改完成后,在enable表
hbase(main):012:0> disable 'linkcdc:cdc_con_tag'
0 row(s) in 2.2400 seconds
hbase(main):013:0> alter 'linkcdc:cdc_con_tag',{NAME => 'con_tag',COMPRESSION => 'SNAPPY'}
Updating all regions with the new schema...
4/4 regions updated.
Done.
0 row(s) in 1.8780 seconds
hbase(main):014:0>
hbase(main):015:0* enable 'linkcdc:cdc_con_tag'
0 row(s) in 1.2260 seconds
执行major compact
major_compact是很重的后台操作,非常占用cpi和io,需要谨慎操作,可以通过grafana->HBase监控可以查看压缩队列。
hbase(main):019:0* major_compact 'linkcdc:cdc_con_tag'
0 row(s) in 0.0360 seconds
执行后效果
如下图可以看到效果还是非常明显,由原来的20多G减少为不到10G