前言:大合并,就是将一个Region下的所有StoreFile合并成一个StoreFile文件,在大合并的过程中,之前删除的行和过期的版本都会被删除。大合并一般一周做一次,由于执行期间会对整个集群的磁盘和带宽带来较大影响,一般建议设置hbase.hregion.majorcompaction设为0来禁用该功能,并在夜间集群负载较低时通过定时任务脚本来执行。
#!/bin/bash
#author:Wang Kuan
#date:2019-05-16
#major_compaction is use short I/O and bandwidth consumption for low latency of subsequent queries
metrics_status="metrics_status.txt"
metrics_file_count="metrics_file_count.txt"
metrics_filecount_gt="metrics_fiflecount_gc.txt"
metrics_filecount_sorted="metrics_filecount_sorted.txt"
tables_need_compact="tables_need_conpact.txt"
rm -rf $metrics_status $metrics_file_count $metrics_filecount_gt $metrics_filecount_sorted $tables_need_compact
compact_num=10
storefile_num=40
echo "status 'detailed'" | hbase