Created 10-20-2017 09:15 AM
Hi All,
I'm having the requirement of retrieving a Particular Rowkey from Hbase tables and Store those in HDFS for taking Backup, is there any option to achieve this scenario.I tried with scan 'TABLENAME',{FILTER =>"(PrefixFilter ('ROWKEY'))"} for retrieving, but i don't know how to store those ROWKEY information in HDFS. Is there best way to do this.
Created 10-20-2017 12:55 PM
Hi @Mathi Murugan,
The simply way to retrieve particular Rowkey from hbase to HDFS is,
Run the scan command using echo with hbase shell and store the results to local then copy the results to HDFS.
Sample Shell script would be
bash# cat hbase_scan.sh echo "scan 'test_use',{FILTER =>\"(PrefixFilter ('4'))\"}"|hbase shell>hbase.txt hadoop fs -put -f /<local-path-to>/hbase.txt /<hadoop-path>/ wait rm <local-path-to>/hbase.txt
In this script we are storing the scan results to hbase.txt file in local
Then copying the file to HDFS
Then deleting the local file.
Created 10-20-2017 03:13 PM
You can use this one line command
echo "scan 'test_1',{FILTER =>\"(PrefixFilter ('r1'))\"}" | hbase shell -n | grep "column=" | hdfs dfs -appendToFile - /tmp/hbaseresults.txt
Here 'test_1' is the table name, 'r1' is the row key and /tmp/hbaseresults.txt is the hdfs file path. You can replace these values with your values.
Thanks,
Aditya