Steps to restart hdfs
======================
sudo service hadoop-master stop;
sudo service hadoop-master start;
hadoop dfsadmin -safemode leave;
sudo jps
Steps to restart hbase
======================
* kill hmaster,regionserver and zookeeper
* rm -Rf /usr/lib/hbase-1.1.2/logs/*
* /usr/lib/hbase-1.1.2/bin/start-hbase.sh
* hbase shell
********************************************************************************
*****************************************************
General Commands
********************************************************************************
*****************************************************
status:
======
Provides the status of HBase, for example, the number of servers.
Ex:
--
status
--------------------------------------------------------------------------------
----------------------------------------------------
version:
=======
Provides the version of HBase being used.
Ex:
--
version
--------------------------------------------------------------------------------
----------------------------------------------------
table_help:
==========
Provides help for table-reference commands.
Ex:
--
table_help
--------------------------------------------------------------------------------
----------------------------------------------------
whoami:
======
Provides information about the user.
Ex:
--
whoami
********************************************************************************
*****************************************************
Data Definition Language
********************************************************************************
*****************************************************
CREATE TABLE
============
Creates a table.
Syntax
------
create '<table name>','<column family>'
Ex
--
create 'emp', 'personal data', 'professional data'
Verification
------------
list
--------------------------------------------------------------------------------
----------------------------------------------------
LISTING TABLES
==============
Lists all the tables in HBase.
Syntax
------
list
Ex
list
--------------------------------------------------------------------------------
----------------------------------------------------
DISABLING A TABLE
=================
Disables a table.
Syntax
------
disable 'table name'
disable_all 'regex'
Ex
--
disable 'emp'
disable_all 'e.*'
Verification
------------
is_disabled 'emp'
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
ENABLING A TABLE
================
Enables a table.
Syntax
------
enable 'table name'
enable_all 'regex'
Ex
--
enable 'emp'
enable_all 'e.*'
Verification
------------
is_enabled 'emp'
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
DESCRIBE
========
Provides the description of a table.
Syntax
------
describe 'table name'
Ex
--
describe 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
ALTER
=====
Changing the Maximum Number of Cells of a Column Family
syntax
------
alter 't1', NAME => 'f1', VERSIONS => 5
Ex
--
alter 'emp', NAME => 'personal data', VERSIONS => 5
Verification
------------
describe 'emp'
--------------------------------------------------------------------------------
-----------------------------------------------------
Table Scope Operators
=====================
MAX_FILESIZE,
READONLY,
MEMSTORE_FLUSHSIZE,
DEFERRED_LOG_FLUSH
--------------------------------------------------------------------------------
-----------------------------------------------------
ALTER
=====
Table Scope Operators - Setting Read Only
syntax
------
alter 't1', READONLY(option)
Ex
--
alter 'emp', READONLY
Verification
------------
describe 'emp'
--------------------------------------------------------------------------------
-----------------------------------------------------
ALTER
=====
Table Scope Operators - Removing Table Scope Operators
syntax
------
alter 't1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE'
Ex
--
alter 'emp', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE'
--------------------------------------------------------------------------------
-----------------------------------------------------
ALTER
=====
Deleting a Column Family
syntax
------
alter ' table name ', 'delete' => 'column family '
Ex
--
alter 'emp','delete'=>'professional data'
Verification
------------
describe 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
EXISTS
======
Verifies whether a table exists.
syntax
------
exists 'table name'
Ex
--
exists 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
DROP A TABLE
============
Drops a table from HBase.
syntax
------
drop 'table name'
drop_all 'regex'
Ex
--
disable 'emp'
drop 'emp'
disable_all 'e.*'
drop_all 'e.*'
Verification
------------
exists 'emp'
list
--------------------------------------------------------------------------------
----------------------------------------------------
TRUNCATE:
========
Disables, drops, and recreates a specified table.
Syntax
------
truncate 'table name'
Ex
--
truncate 'emp'
Verification
------------
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
SHUTTING DOWN HBASE
===================
* exit the shell
Ex
--
exit
* Stopping HBase
Ex
--
./bin/stop-hbase.sh
********************************************************************************
*****************************************************
Data Manipulation Language
********************************************************************************
*****************************************************
CREATE DATA
===========
Puts a cell value at a specified column in a specified row in a particular
table.
Syntax
------
put '<table name>','row1','<colfamily:colname>','<value>'
Ex
--
put 'emp','1','personal data:name','raju'
put 'emp','1','personal data:city','hyderabad'
put 'emp','1','professional data:designation','manager'
put 'emp','1','professional data:salary','50000'
Verification
------------
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
UPDATE DATA
===========
update an existing cell value using the put command
Syntax
------
put 'table name','row ','Column family:column name','new value'
Ex
--
put 'emp','1','personal data:city','Delhi'
Verification
------------
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
READ DATA
=========
read a cell value using the get command
Syntax
------
get '<table name>','row1'
get 'table name', 'rowid', {COLUMN => 'column family:column name '}
Ex
--
get 'emp', '1'
get 'emp', '1', {COLUMN=>'personal data:name'}
--------------------------------------------------------------------------------
----------------------------------------------------
DELETE DATA
===========
Deletes in a table.
Syntax
------
delete '<table name>', '<row>', '<column name >', '<time stamp>'
deleteall '<table name>','<row>'
Ex
--
delete 'emp', '1', 'personal data:city', 1417521848375
deleteall 'emp','1'
Verification
------------
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
HBASE SCAN
==========
Scans and returns the table data.
Syntax
------
scan '<table name>'
Ex
--
scan 'emp'
--------------------------------------------------------------------------------
----------------------------------------------------
COUNT
=====
Counts and returns the number of rows in a table.
Syntax
------
count '<table name>'
Ex
--
count 'emp'
********************************************************************************
*****************************************************
HBASE SECURITY
********************************************************************************
*****************************************************
GRANT
=====
grant permissions to users in HBase
Syntax
------
grant <user> <permissions> [<table> [<column family> [<column qualifier>]]
R - represents read privilege.
W - represents write privilege.
X - represents execute privilege.
C - represents create privilege.
A - represents admin privilege.Ex
Ex
--
grant 'Tutorialspoint', 'RWXCA'
--------------------------------------------------------------------------------
----------------------------------------------------
REVOKE
======
used to revoke a user's access rights of a table
Syntax
------
revoke <user>
Ex
--
revoke 'Tutorialspoint'
--------------------------------------------------------------------------------
----------------------------------------------------
USER_PERMISSION
===============
list all the permissions for a particular table
Syntax
------
user_permission 'tablename'
Ex
--
user_permission 'emp'

Quick reference for HBase shell commands

  • 1.
    Steps to restarthdfs ====================== sudo service hadoop-master stop; sudo service hadoop-master start; hadoop dfsadmin -safemode leave; sudo jps Steps to restart hbase ====================== * kill hmaster,regionserver and zookeeper * rm -Rf /usr/lib/hbase-1.1.2/logs/* * /usr/lib/hbase-1.1.2/bin/start-hbase.sh * hbase shell ******************************************************************************** ***************************************************** General Commands ******************************************************************************** ***************************************************** status: ====== Provides the status of HBase, for example, the number of servers. Ex: -- status -------------------------------------------------------------------------------- ---------------------------------------------------- version: ======= Provides the version of HBase being used. Ex: -- version -------------------------------------------------------------------------------- ---------------------------------------------------- table_help: ========== Provides help for table-reference commands. Ex: -- table_help -------------------------------------------------------------------------------- ---------------------------------------------------- whoami: ====== Provides information about the user. Ex: -- whoami ******************************************************************************** ***************************************************** Data Definition Language ******************************************************************************** ***************************************************** CREATE TABLE ============ Creates a table. Syntax ------ create '<table name>','<column family>'
  • 2.
    Ex -- create 'emp', 'personaldata', 'professional data' Verification ------------ list -------------------------------------------------------------------------------- ---------------------------------------------------- LISTING TABLES ============== Lists all the tables in HBase. Syntax ------ list Ex list -------------------------------------------------------------------------------- ---------------------------------------------------- DISABLING A TABLE ================= Disables a table. Syntax ------ disable 'table name' disable_all 'regex' Ex -- disable 'emp' disable_all 'e.*' Verification ------------ is_disabled 'emp' scan 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- ENABLING A TABLE ================ Enables a table. Syntax ------ enable 'table name' enable_all 'regex' Ex -- enable 'emp' enable_all 'e.*' Verification ------------ is_enabled 'emp' scan 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- DESCRIBE ========
  • 3.
    Provides the descriptionof a table. Syntax ------ describe 'table name' Ex -- describe 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- ALTER ===== Changing the Maximum Number of Cells of a Column Family syntax ------ alter 't1', NAME => 'f1', VERSIONS => 5 Ex -- alter 'emp', NAME => 'personal data', VERSIONS => 5 Verification ------------ describe 'emp' -------------------------------------------------------------------------------- ----------------------------------------------------- Table Scope Operators ===================== MAX_FILESIZE, READONLY, MEMSTORE_FLUSHSIZE, DEFERRED_LOG_FLUSH -------------------------------------------------------------------------------- ----------------------------------------------------- ALTER ===== Table Scope Operators - Setting Read Only syntax ------ alter 't1', READONLY(option) Ex -- alter 'emp', READONLY Verification ------------ describe 'emp' -------------------------------------------------------------------------------- ----------------------------------------------------- ALTER ===== Table Scope Operators - Removing Table Scope Operators syntax ------ alter 't1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE' Ex -- alter 'emp', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE'
  • 4.
    -------------------------------------------------------------------------------- ----------------------------------------------------- ALTER ===== Deleting a ColumnFamily syntax ------ alter ' table name ', 'delete' => 'column family ' Ex -- alter 'emp','delete'=>'professional data' Verification ------------ describe 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- EXISTS ====== Verifies whether a table exists. syntax ------ exists 'table name' Ex -- exists 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- DROP A TABLE ============ Drops a table from HBase. syntax ------ drop 'table name' drop_all 'regex' Ex -- disable 'emp' drop 'emp' disable_all 'e.*' drop_all 'e.*' Verification ------------ exists 'emp' list -------------------------------------------------------------------------------- ---------------------------------------------------- TRUNCATE: ======== Disables, drops, and recreates a specified table. Syntax ------ truncate 'table name' Ex
  • 5.
    -- truncate 'emp' Verification ------------ scan 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- SHUTTINGDOWN HBASE =================== * exit the shell Ex -- exit * Stopping HBase Ex -- ./bin/stop-hbase.sh ******************************************************************************** ***************************************************** Data Manipulation Language ******************************************************************************** ***************************************************** CREATE DATA =========== Puts a cell value at a specified column in a specified row in a particular table. Syntax ------ put '<table name>','row1','<colfamily:colname>','<value>' Ex -- put 'emp','1','personal data:name','raju' put 'emp','1','personal data:city','hyderabad' put 'emp','1','professional data:designation','manager' put 'emp','1','professional data:salary','50000' Verification ------------ scan 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- UPDATE DATA =========== update an existing cell value using the put command Syntax ------ put 'table name','row ','Column family:column name','new value' Ex -- put 'emp','1','personal data:city','Delhi' Verification ------------ scan 'emp' -------------------------------------------------------------------------------- ----------------------------------------------------
  • 6.
    READ DATA ========= read acell value using the get command Syntax ------ get '<table name>','row1' get 'table name', 'rowid', {COLUMN => 'column family:column name '} Ex -- get 'emp', '1' get 'emp', '1', {COLUMN=>'personal data:name'} -------------------------------------------------------------------------------- ---------------------------------------------------- DELETE DATA =========== Deletes in a table. Syntax ------ delete '<table name>', '<row>', '<column name >', '<time stamp>' deleteall '<table name>','<row>' Ex -- delete 'emp', '1', 'personal data:city', 1417521848375 deleteall 'emp','1' Verification ------------ scan 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- HBASE SCAN ========== Scans and returns the table data. Syntax ------ scan '<table name>' Ex -- scan 'emp' -------------------------------------------------------------------------------- ---------------------------------------------------- COUNT ===== Counts and returns the number of rows in a table. Syntax ------ count '<table name>' Ex -- count 'emp' ******************************************************************************** ***************************************************** HBASE SECURITY ******************************************************************************** ***************************************************** GRANT
  • 7.
    ===== grant permissions tousers in HBase Syntax ------ grant <user> <permissions> [<table> [<column family> [<column qualifier>]] R - represents read privilege. W - represents write privilege. X - represents execute privilege. C - represents create privilege. A - represents admin privilege.Ex Ex -- grant 'Tutorialspoint', 'RWXCA' -------------------------------------------------------------------------------- ---------------------------------------------------- REVOKE ====== used to revoke a user's access rights of a table Syntax ------ revoke <user> Ex -- revoke 'Tutorialspoint' -------------------------------------------------------------------------------- ---------------------------------------------------- USER_PERMISSION =============== list all the permissions for a particular table Syntax ------ user_permission 'tablename' Ex -- user_permission 'emp'