用于hbase命令的Shell脚本|数'表'

时间:2017-07-28 10:57:21

标签: unix hbase sh hbase-shell

我正在尝试使用count命令获取hbase中的表列表的计数。我目前正将所有命令放在input.txt。

示例输入

import boto3

conn = boto3.client('s3',
                region_name="eu-west-1",
                endpoint_url="endpoint",
                config=Config(signature_version="s3", s3={'addressing_style': 'path'}))

命令

count  'test.table1', INTERVAL => 10000000, CACHE => 10000000
count 'test.table2', INTERVAL => 10000000, CACHE => 10000000

有没有办法编写shell脚本,以便我可以在nohup.out上运行,并通过shell脚本获取如下所示的输出,以便我可以为任意数量的表运行它:

hbase shell ./input.txt

感谢这方面的任何帮助

1 个答案:

答案 0 :(得分:2)

这段代码可以帮助您获取HBase中所有表的记录数。

#!/bin/bash echo 'list' | hbase shell | sed -e '1,/TABLE/d' -e '/seconds/,$d' | while IFS='' read -r line || [[ -n "$line" ]]; do echo "count '$line'" | hbase shell | tail -n 1 | xargs echo "$line,">> ./tableCount.log done

在HBase 1.1.8中测试过,输出将存储在tableCount.log中。

相关问题