hbase手动compact与split-创新互联
#!/bin/bash die () { echo >&2 "$@" echo "usage:" echo " $0 check|split table_name [split_size]" exit 1 } [[ "$#" -lt 2 ]] && die "at least 2 arguments required, $# provided" COMMAND=$1 TABLE=$2 SIZE="${3:-1073741824}" split() { region_key=`python /home/hduser/hbase/hbase-scan.py -t hbase:meta -f "RowFilter (=, 'substring:$1')"` echo "split '$region_key'" | hbase shell } if [ "$COMMAND" != "check" ] ; then for region in `hadoop fs -ls /hbase/data/default/$TABLE | awk {'print $8'}` do [[ ${region##*/} =~ ^\. ]] && continue [[ `hadoop fs -du -s $region | awk {'print $1'}` -gt $SIZE ]] && split ${region##*/} done # check after split sleep 60 fi for region in `hadoop fs -ls /hbase/data/default/$TABLE | awk {'print $8'}` do [[ ${region##*/} =~ ^\. ]] && continue [[ `hadoop fs -du -s $region | awk {'print $1'}` -gt $SIZE ]] && echo "${region##*/} (`hadoop fs -du -s -h $region | awk {'print $1 $2'}`) is a huge region" || echo "${region##*/} (`hadoop fs -du -s -h $region | awk {'print $1 $2'}`) is a small region" done
hbase-scan.py
创新互联是一家专注于成都做网站、成都网站设计与策划设计,吴桥网站建设哪家好?创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:吴桥等地区。吴桥做网站价格咨询:13518219792import subprocess import datetime import argparse import csv import gzip import happybase import logging def connect_to_hbase(): return happybase.Connection('itr-hbasetest01') def main(): logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s: %(message)s',level=logging.INFO) argp = argparse.ArgumentParser(description='EventLog Reader') argp.add_argument('-t','--table', dest='table', default='eventlog') argp.add_argument('-p','--prefix', dest='prefix') argp.add_argument('-f','--filter', dest='filter') argp.add_argument('-l','--limit', dest='limit', default=10) args = argp.parse_args() hbase_conn = connect_to_hbase() table = hbase_conn.table(args.table) logging.info("scan start") scanner = table.scan(row_prefix=args.prefix, batch_size=1000, limit=int(args.limit), filter=args.filter) logging.info("scan done") i = 0 for key, data in scanner: logging.info(key) print key i+=1 logging.info('%s rows read in total', i) if __name__ == '__main__': main()
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:hbase手动compact与split-创新互联
网站网址:http://lswzjz.com/article/jpiig.html