Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export data from HBase shell

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
like image 769
Yogzzz Avatar asked Nov 26 '13 03:11

Yogzzz


People also ask

What is the use of HBase shell commands?

This shell commands allows the programmer to define table schemas and data operations using complete shell mode interaction Whichever command we use, it’s going to reflect in HBase data model We use HBase shell commands in operating system script interpreters like Bash shell

How to read data from a table in HBase?

The get command and the get () method of HTable class are used to read data from a table in HBase. Using get command, you can get a single row of data at a time.

How to backup a HBase table?

And the jars provided all seem to want a classname as the first argument, not just export. If you can use the Hbase command instead to backup hbase tables you can use the Hbase ExportSnapshot Tool which copies the hfiles,logs and snapshot metadata to other filesystem (local/hdfs/s3) using a map reduce job.

How can we interact with HBase using Java API?

We can interact with HBase using this both methods. The only difference between these two is Java API use java code to connect with HBase and shell mode use shell commands to connect with HBase. HBase uses Hadoop files as storage system to store the large amounts of data.


1 Answers

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.

like image 170
Nathan Zburivsky Avatar answered Sep 23 '22 13:09

Nathan Zburivsky