0

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

样本输入

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

命令

hbase shell ./input.txt

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

table1,500000
table2,300

感谢这方面的任何帮助

4

1 回答 1

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 中。

于 2017-07-29T10:05:02.047 回答