How to import data to hbase database

0 votes
I have a CSV file having data. how to this data to HBase? How it is 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? if there provide me with the sample?
Jul 23, 2019 in Big Data Hadoop by Joshua
2,911 views

1 answer to this question.

0 votes

First you have to have the file in hdfs. 

Then there 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

command:

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

command:

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

command:

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

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

command:

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

command: 

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 23, 2019 by Kiran

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,636 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,882 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,591 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,303 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,033 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,540 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
108,854 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,616 views
0 votes
1 answer

How to import data to hbase database?

There are 3 Ways to Load Data ...READ MORE

answered Jul 10, 2019 in Big Data Hadoop by Karan Reddy
5,391 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,205 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