定时执行脚本
#!/bin/bash
source /etc/profile
sh ./hbase shell <<EOF
major_compact 'table_name'
EOF
major_compact 语法:
hbase(main):024:0> help 'major_compact'
Run major compaction on passed table or pass a region row
to major compact an individual region. To compact a single
column family within a region specify the region name
followed by the column family name.
Examples:
Compact all regions in a table:
hbase> major_compact 't1'
hbase> major_compact 'ns1:t1'
Compact an entire region:
hbase> major_compact 'r1'
Compact a single column family within a region:
hbase> major_compact 'r1', 'c1'
Compact a single column family within a table:
hbase> major_compact 't1', 'c1'
Compact table with type "MOB"
hbase> major_compact 't1', nil, 'MOB'
Compact a column family using "MOB" type within a table
hbase> major_compact 't1', 'c1', 'MOB'
major_compact 最好禁用自动major_compact ,而是手动major_compact 。时间选择在业务低峰期执行。
而且避免影响业务要进行限速限并发等操作,因为major_compact 会消耗较多的IO和磁盘。具体是如何配置后续再继续研究