HBase
HBase Installation on Ubuntu
In this tutorial- you will learn, Apache HBase Installation Modes How to Download Hbase tar file...
In HBase, we can create table operations in two ways
We will learn to use both to create Tables.
In this section, we are going to perform some of the operations using Java coding through Java API.
Through Java API, we can create tables in HBase and also load data into tables using Java coding.
Establishing connection through Java API:
The Following steps guide us to develop Java code to connect HBase through Java API.
Step 1) In this step, we are going to create a Java project in eclipse for HBase connection.
Creation of new project name "HbaseConnection" in eclipse.
For Java related project set up or creation of program
If we observe the screenshot above.
Step 2) On eclipse home page follow the following steps
Right click on project -> Select Build Path -> Configure build path
From above screenshot
After clicking Configure Build path, it will open another window as shown in below screenshot
In this step, we will add relevant HBase jars into java project as shown in the screenshot.
After adding these jars, it will show under project "src" location. All the Jar files that fall under the project are now ready for usage with Hadoop ecosystem.
Step 3) In this step by using HBaseConnection.java, the HBase Connection would be established through Java Coding
From the screenshot above we are performing following functions.
The below coding is going to
Code Placed under HBaseConnection_Java document
// Place this code inside Hbase connection import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; Import org.apache.hadoop.hbase.client.HBaseAdmin; public class HBaseConnection { public static void main(String[] args) throws IOException { HBaseConfigurationhc = new HBaseConfiguration(new Configuration()); HTableDescriptorht = new HTableDescriptor("guru99"); ht.addFamily( new HColumnDescriptor("education")); ht.addFamily( new HColumnDescriptor("projects")); System.out.println( "connecting" ); HBaseAdminhba = new HBaseAdmin( hc ); System.out.println( "Creating Table" ); hba.createTable( ht ); System.out.println("Done......"); } }
This is required code you have to place in HBaseConnection.java and have to run a java program
After running this program, it is going to establish a connection with HBase and in turn, it will create a table with column names.
Step 4) We can check whether "guru99" table is created with two columns in HBase or not by using HBase shell mode with "list" command.
The "list" command gives information about all the tables that is created in HBase.
In this screen, we are going to do
Syntax to Create a table is
Syntax: create <tablename>, <columnfamilyname>
Example:-
hbase(main):001:0> create 'education' ,'guru99' 0 rows(s) in 0.312 seconds =>Hbase::Table – education
The above example explains how to create a table in HBase with the specified name given according to the dictionary or specifications as per column family. In addition to this, we can also pass some table-scope attributes as well into it.
create 'guru99', {NAME=>'Edu', VERSIONS=>213423443}
Summary:
HBase is a column-oriented NoSQL database for storing a large amount of data on top of Hadoop ecosystem. Handling tables in HBase is a very crucial thing because all important functionalities such as Data operations, Data enhancements and Data modeling we can be performed through only tables in HBase. Tables perform the following functions 1) Creation of tables with column names and rows 2) Inserting values into tables 3) Retrieving values from tables
In this tutorial- you will learn, Apache HBase Installation Modes How to Download Hbase tar file...
In this tutorial, you will learn: Write Data to HBase Table: Shell Read Data from HBase Table:...
Storage Mechanism in HBase HBase is a column-oriented database and data is stored in tables. The...
What is HBase? HBase is an open-source, column-oriented distributed database system in a Hadoop ...
Download PDF Following are frequently asked questions in interviews for freshers as well...
After successful installation of HBase on top of Hadoop, we get an interactive shell to execute...