Export data from the HBase shell

I am trying to export data from HBase Shell to a text file that I can parse and add to 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 file.

How can I remove shell input and resume and just add data lines to a text file:

For example: Shell in I want to skip:

 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 
+7
source share
3 answers

try it

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

Since the results are prefixed with a single space, the remaining elements will be filtered.

+10
source

You can add one more step to your pipeline to skip the first 4 lines that contain all the unwanted materials and achieve this:

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

You can also just do a bit of work with the line here in the Bash shell, for example:

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

Source: https://habr.com/ru/post/958821/


All Articles