2017-07-28 139 views
0

我正在嘗試使用count命令獲取hbase中的表的列表的計數。我目前將所有的命令放在input.txt中。hbase命令的shell腳本|計數'表'

樣品輸入

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

命令

hbase shell ./input.txt 

有沒有寫一個shell腳本,這樣我可以通過shell腳本上的nohup.out運行,並得到像下面的輸出,這樣的方式我可以運行它的任何數量的表:

table1,500000 
table2,300 

欣賞這方面的任何幫助

回答

1

這段代碼可能會幫助您獲取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。

+0

嗨,感謝您的信息..我們是如何傳遞表名列表作爲輸入文件? – divyanair

+0

不,上面的代碼首先獲取HBase中的表的列表,然後得到no。每個表的行數。 –