从HBase外壳导出数据

从HBase外壳导出数据,hbase,hbase-shell,Hbase,Hbase Shell,我正试图将数据从HBase外壳导出到一个文本文件中,我可以对其进行解析,并将其添加到msysql数据库中 我当前正在使用以下命令: echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell > registration.txt 它将所有内容从hbase外壳导出到registration.txt 如何删除shell简介和摘要,并将数据行附加到文本文件中: 我想省略的是: HBase Shell;

我正试图将数据从HBase外壳导出到一个文本文件中,我可以对其进行解析,并将其添加到msysql数据库中

我当前正在使用以下命令:

echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell > registration.txt
它将所有内容从hbase外壳导出到registration.txt

如何删除shell简介和摘要,并将数据行附加到文本文件中:

我想省略的是:

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

您可以在管道中再添加一个步骤,跳过包含所有不需要的内容的前4行,并实现以下目标:

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

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

由于结果的前缀是单空格,剩余的内容将被过滤掉。

您也可以通过在Bash shell中使用here字符串来简单地处理一些事情,例如:

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

它可以工作!直接在shell中运行。不在HBase shell promptNot working中,它会获取时间戳和值=,并且不能很好地处理诸如pdf之类的二进制文件