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, 2019 in Big Data Hadoop by Rina
5,434 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.png3.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

To know more, It's recommended to join Big Data Certification today.

answered Jul 10, 2019 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,350 points
1,645 views
0 votes
1 answer

How to import PIG data into HBase?

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

answered Feb 15, 2019 in Big Data Hadoop by Omkar
• 69,220 points
1,916 views
0 votes
1 answer

How to fetch more data from database while using Sqoop import?

Hey. You guessed it right. The max ...READ MORE

answered May 15, 2019 in Big Data Hadoop by Gani
2,601 views
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 12, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
7,331 views
+1 vote
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
• 11,380 points
11,072 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
• 11,380 points
2,570 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
109,053 views
–1 vote
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,350 points
4,639 views
0 votes
1 answer

How to import data to hbase database?

First you have to have the file ...READ MORE

answered Jul 23, 2019 in Big Data Hadoop by Kiran
2,948 views
0 votes
2 answers

Hey for all, how to get on large data i want use in hadoop?

Hi, To work with Hadoop you can also ...READ MORE

answered Jul 30, 2019 in Big Data Hadoop by Sunny
1,234 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP