Export data from HBase shell
Asked Answered
H

3

7

Im trying to export data from HBase Shell to a text file which I can parse, and add to a msysql db.

I am currently using the following command:

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

which exports everything from the hbase shell to the registration.txt.

How can I remove the shell intro, and the summary and just append the rows of data to the text file:

Eg: Shell into I want to omit:

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

Summary I want to omit:

ROW                                      COLUMN+CELL  
4419 row(s) in 12.9840 seconds
Hep answered 26/11, 2013 at 3:45 Comment(0)
B
10

Try this

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

Since the results are prefixed with single space, remaining stuff would be filtered out.

Bettinabettine answered 27/11, 2013 at 4:29 Comment(2)
It works! Run in directly in shell. Not in HBase shell promptChaplin
Not working it gets timestamp and value=' and doesn't work well with binary files like pdfA
T
1

You could add one more step to your pipeline to skip the first 4 lines which contain all the undesired stuff and achieve that :

$ echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell \
   |  awk 'NR>5{print$0}'
Tasker answered 26/11, 2013 at 14:49 Comment(0)
P
0

You can also simply things a bit by making use of a here string in a Bash shell for example:

$ hbase shell <<< "scan 'registration',{COLUMNS=>'registration:status'}" \
    | grep "^ " > registration.txt
Pitchdark answered 24/9, 2015 at 3:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.