How to import data to hbase database?

0 votes
I have a CSV file having data. How to transfer this data to hbase?  What should I do if I want to upload data to one column family or to multiple column families? or else if not CSV file which type of data file(i mean data format ) is needed to import to hbase?
Jul 10 in Big Data Hadoop by Rina
15 views

1 answer to this question.

0 votes

There are 3 Ways to Load Data From HDFS to HBase

1.Using ImportTsv to load txt to HBase

a) Create table in hbase

command:

create ‘tab3′,’cf’

f5NtH1gbl0Aqal2Q7u5SFPYrdXYXo8vsUw.png

b) Uploading simple1.txt to HDFS

bin/hadoop fs -copyFromLocal simple1.txt  /user/hadoop/simple1.txt

The context in the txt is:

1,tom
2,sam
3,jerry
4,marry
5,john

c) Using ImportTsv to load txt to HBase

bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.separator=”,” 
-Dimporttsv.columns=HBASE_ROW_KEY,cf tab4 /user/hadoop/simple1.txt

ImportTsv execute result:
 

_ZxrFAhcMAgTykPQu80pQrNuyy3nySv1nw.png

sp1N4TXzj8D0qD4t5swscrI5aSTOYWF9BA.png


2.Using completebulkload to load txt to HBase

a) creating table in hbase

create ‘hbase-tb1-003′,’cf’

HAaRJ6GNXgNBk5q8fYSXSIzIJKoZcthEBA.png
b) Using ImportTsv to generate HFile for txt in HDFS

bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.separator=”,” 
-Dimporttsv.bulk.output=hfile_tmp5 -Dimporttsv.columns=HBASE_ROW_KEY,cf hbase-tbl-003 /user/hadoop/simple1.txt

This command will be executed by MapReduce job:

1B7U89pKAH6D2uEGkzz5REIIO5gC6lNp-w.png

As a result, the Hfile hfile_tmp5 is generated.

JkSlkhfeNZeTi4Tt_Bwk4Ni5jgbcBO5ZbA.png

But the data wasn’t loaded into the Hbase table: hbase-tb1-003.

etd9ke8tBUSzGlx06BygfMJhLgIPX6mFpg.png
3.Using completebulkload to load Hfile to HBase

hadoop jar lib/hbase-server-0.98.13-hadoop2.jar completebulkload hfile_tmp5 hbase-tbl-003

GMuQk1wIDnNJkaohpaMEMb0dq_uJAkg_dA.png

Result:

4FnNWtDAGS2-S7hi62hreBnQ28dGGbIJcA.png

answered Jul 10 by Karan Reddy

Related Questions In Big Data Hadoop

0 votes
1 answer

How to import data to HBase from SQL server?

You can easily import the data from ...READ MORE

answered Apr 20, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
291 views
0 votes
1 answer

How to import PIG data into HBase?

Follow the below steps to do it: # ...READ MORE

answered Feb 14 in Big Data Hadoop by Omkar
• 67,120 points
100 views
0 votes
1 answer
0 votes
1 answer

How to move data from Oracle database to Hadoop?

Yes, you heard it correctly. Apache Sqoop is ...READ MORE

answered Apr 11, 2018 in Big Data Hadoop by nitinrawat895
• 10,110 points
1,489 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,110 points
2,052 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,110 points
196 views
0 votes
10 answers

hadoop fs -put command?

copy command can be used to copy files ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Sujay
10,495 views
0 votes
1 answer

Hadoop dfs -ls command?

In your case there is no difference ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by kurt_cobain
• 9,240 points
765 views
0 votes
1 answer

How to load data from HDFS into pig relation?

Hey, To load data from HDFS to pig ...READ MORE

answered May 7 in Big Data Hadoop by Gitika
• 19,720 points
21 views
0 votes
1 answer