2013-11-26 62 views
6

我試圖將數據從HBase Shell導出到我可以解析的文本文件,並添加到msysql數據庫。從HBase shell導出數據

我目前使用下面的命令:

echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell > registration.txt 

其中出口一切從HBase的外殼到registration.txt。

我怎樣才能去掉外殼的介紹,並總結,只是將數據追加到文本文件中的行:

如:殼牌進我想省略:

HBase Shell; enter 'help<RETURN>' for list of supported commands. 
Type "exit<RETURN>" to leave the HBase Shell 
Version 0.94.5-mapr, Wed May 1 7:42:07 PDT 2013 

總結我想省略:

ROW          COLUMN+CELL 
4419 row(s) in 12.9840 seconds 

回答

10

試試這個

echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell | grep "^ " > registration.txt 

由於結果與單一的空間前綴,剩下的東西就都被過濾掉。

+0

它的工作原理!直接在shell中運行。不在HBase shell提示符下 – Sakthivel

1

你可以一個步驟添加到您的管道跳過前4行包含所有不需要的東西,做到這一點:

$ echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell \ 
    | awk 'NR>5{print$0}' 
0

你也可以簡單的事情有點通過利用這裏串在Bash shell例如:

$ hbase shell <<< "scan 'registration',{COLUMNS=>'registration:status'}" \ 
    | grep "^ " > registration.txt