Apache HBase is an open source, non-relational, distributed
database modeled after Google's BigTable and is written in Java. It is
developed as part of Apache Software Foundation's Apache Hadoop project
and runs on top of HDFS (Hadoop Distributed File System), providing
BigTable-like capabilities for Hadoop. That is, it provides a
fault-tolerant way of storing large quantities of sparse data (small
amounts of information caught within a large collection of empty or
unimportant data, such as finding the 50 largest items in a group of 2
billion records, or finding the non-zero items representing less than
0.1% of a huge collection).
Pre Requirements
1) A machine with Ubuntu 14.04 LTS operating system.
2) Apache Hadoop pre installed (How to install Hadoop on Ubuntu 14.04)
3) Apache HBase pre installed (How to install HBase on Ubuntu 14.04)
HBase Shell Usage
HBase contains a shell using which you can communicate with HBase. HBase uses the Hadoop File System to store its data. It will have a master server and region servers. The data storage will be in the form of regions (tables). These regions will be split up and stored in region servers.
The master server manages these region servers and all these tasks take place on HDFS. Given below are some of the commands supported by HBase Shell.
Step 1 - Change the directory to /usr/local/hbase/bin
Step 2 - Start all hbase daemons.
Step 3 - The JPS (Java Virtual Machine Process Status Tool) tool is limited to reporting information on JVMs for which it has the access permissions.
Once the HBase is up and running check the web-ui of the components as described below
Step 4 - You can start the HBase interactive shell using "hbase shell" command as shown below.
List is a command used to get the list of all the tables in HBase.
Status command returns the status of the system including the details of the servers running on the system.
Version command returns the version of HBase used in your system
Table Help command guides you what and how to use table-referenced commands.
Whoami command returns the user details of HBase.
Create table You can create a table using the create command, here you must specify the table name and the Column Family name.
Verify the creation
Drop table Using the drop command, you can delete a table. Before dropping a table, you have to disable it.
drop_all This command is used to drop the tables matching the “regex†given in the command.
Verify
Disable Table To delete a table or change its settings, you need to first disable the table using the disable command. You can re-enable it using the enable command.
Verification After disabling the table, you can still sense its existence through list and exists commands. You cannot scan it.
is_disabled This command is used to find whether a table is disabled.
disable_all This command is used to disable all the tables matching the given regex.
Enable Table
Verification After enabling the table, scan it. If you can see the schema, your table is successfully enabled.
is_enabled This command is used to find whether a table is enabled.
enable_all This command is used to enable all the tables matching the given regex.
describe This command returns the description of the table.
alter Alter is the command used to make changes to an
existing table. Using this command, you can change the maximum number of
cells of a column family, set and delete table scope operators, and
delete a column family from a table.
Table Scope Operator Using alter, you can set and remove table scope operators such as MAX_FILESIZE, READONLY, MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH, etc.
Deleting a column family Using alter, you can also delete a column family. Given below is the syntax to delete a column family using alter.
Verification Now verify the data in the table after
alteration. Observe the column family ‘professional’ is no more,
since we have deleted it.
Exists You can verify the existence of a table using the exists command.
Exit from hbase shell
Dont forget to stop habse daemons.
Pre Requirements
1) A machine with Ubuntu 14.04 LTS operating system.
2) Apache Hadoop pre installed (How to install Hadoop on Ubuntu 14.04)
3) Apache HBase pre installed (How to install HBase on Ubuntu 14.04)
HBase Shell Usage
HBase contains a shell using which you can communicate with HBase. HBase uses the Hadoop File System to store its data. It will have a master server and region servers. The data storage will be in the form of regions (tables). These regions will be split up and stored in region servers.
The master server manages these region servers and all these tasks take place on HDFS. Given below are some of the commands supported by HBase Shell.
Step 1 - Change the directory to /usr/local/hbase/bin
$ cd /usr/local/hbase/bin
$ ./start-hbase.sh
$ jps
http://localhost:16010
$ ./hbase shell
hbase> list
Status command returns the status of the system including the details of the servers running on the system.
hbase> status hbase> status 'simple' hbase> status 'summary' hbase> status 'detailed'
Version command returns the version of HBase used in your system
hbase> version
Table Help command guides you what and how to use table-referenced commands.
hbase> table_help
Whoami command returns the user details of HBase.
hbase> whoami
Create table You can create a table using the create command, here you must specify the table name and the Column Family name.
hbase> create 'emp','personal data','professional data'
Verify the creation
hbase> list
Drop table Using the drop command, you can delete a table. Before dropping a table, you have to disable it.
hbase> disable 'emp' hbase> drop 'emp'
drop_all This command is used to drop the tables matching the “regex†given in the command.
hbase> drop_all 'e.*'
hbase> list
Disable Table To delete a table or change its settings, you need to first disable the table using the disable command. You can re-enable it using the enable command.
hbase> disable 'emp'
hbase> scan 'emp'
is_disabled This command is used to find whether a table is disabled.
hbase> is_disabled 'emp'
disable_all This command is used to disable all the tables matching the given regex.
hbase> disable_all 'e.*'
Enable Table
hbase> enable 'emp'
Verification After enabling the table, scan it. If you can see the schema, your table is successfully enabled.
hbase> scan 'emp'
hbase> is_enabled 'emp'
hbase> enable_all 'e.*'
hbase> describe 'emp'
hbase> alter 'emp', NAME => 'personal data', VERSIONS => 5
Table Scope Operator Using alter, you can set and remove table scope operators such as MAX_FILESIZE, READONLY, MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH, etc.
hbase> alter 'emp', READONLY
hbase> alter 'emp','delete'=>'professional data'
hbase> scan 'emp'
hbase> exists 'emp'
hbase> exit
$ ./bin/stop-hbase.sh
Comments
Post a Comment