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
232 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,310 points
607 views
0 votes
1 answer

How to import PIG data into HBase?

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

answered Feb 14, 2019 in Big Data Hadoop by Omkar
• 69,040 points
362 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
657 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 11, 2018 in Big Data Hadoop by nitinrawat895
• 10,920 points
3,536 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
• 10,920 points
5,446 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,920 points
803 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyF ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
33,748 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,310 points
2,056 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
1,185 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
91 views