Professional Documents
Culture Documents
Hbase Command
Hbase Command
-----------------------------------------------------------
create 'tbl_name', 'column_family1', 'column_family2', ...
create 'tbl_name', { NAME => 'column_family1', ... }, { NAME =>
'column_family2', ... }, ...
list 'test'
list 't.*'
scan 'test'
scan 'test',{COLUMNS => 'cf'}
scan 'test',{COLUMNS => 'cf:a'}
scan 'test',{COLUMNS => ['cf:a','cf:b']}
scan 'test',{COLUMNS => 'cf:a', VERSIONS => 5}
scan 'test',{COLUMNS => 'cf', STARTROW => 'row2', LIMIT => 3}
scan 'test',{COLUMNS => 'cf', TIMESTAMP => 1396584133139}
scan 'test',{COLUMNS => 'cf', TIMERANGE => [1396584133139,1404876097252]}
import java.text.SimpleDateFormat
import java.text.ParsePosition
SimpleDateFormat.new("yy/MM/dd HH:mm:ss").parse("08/08/16 20:56:29",
ParsePosition.new(0)).getTime()
import java.util.Date
Date.new(1218900389000).toString()
=> "Sat Aug 16 20:56:29 IST 2008"
-----------------------------------------------------------
ALTER COMMANDS IN HBASE
-----------------------------------------------------------
create 't1', 'cf'
put 't1','r1', 'cf:f1', 'a1'
put 't1','r1', 'cf:f2', 'a2'
put 't1','r2', 'cf:f3', 'a3'
put 't1','r2', 'cf:f2', 'a22'
describe 't1'
disable 't1'
enable 't1'
hbase> list
hbase> list 'abc.*'
hbase> show_filters
==================================================================
HBASE ADMIN COMMANDS
==================================================================
HOW TO ADD PEER
----------------------------------------------------
add_peer '1', "localhost:2181:/hbase-1"
add_peer '2', "localhost:2181:/hbase-2"
add_peer '3', "localhost:2181:/hbase-3"
merge_region 'f7f380290ce31bac8977f9a84e2cc5ab',
'83032a74a27066c0c5cdfe4ab76c101f', true
major_compact 'mytable4'
----------------------------------------------------
HBASE BULK LOADING
----------------------------------------------------
create 'mytable5', 'cf'
create 'mytable6', 'cf'
----------------------------------------------------
hbase org.apache.hadoop.hbase.mapreduce.ImportTsv
-Dimporttsv.columns=HBASE_ROW_KEY,cf:c1,cf:c2 mytable5
hdfs://localhost:8020/hbase_inputs/import/sample1.tsv
----------------------------------------------------
----------------------------------------------------
hbase org.apache.hadoop.hbase.mapreduce.ImportTsv
-Dimporttsv.columns=HBASE_ROW_KEY,cf:c1,cf:c2
-Dimporttsv.bulk.output=hdfs://localhost:8020/hbase_inputs/export datatsv
hdfs://localhost:8020/hbase_inputs/import/sample1.tsv
----------------------------------------------------
hbase org.apache.hadoop.hbase.mapreduce.LoadIncrementalHFiles
hdfs://localhost:8020/hbase_inputs/export 'mytable6'
----------------------------------------------------
----------------------------------------------------
count 'mycount'
----------------------------------------------------
----------------------------------------------------
============================================================================
HBase Filters
============================================================================
Comparison Operators
-----------------------------
LESS (<)
LESS_OR_EQUAL (<=)
EQUAL (=)
NOT_EQUAL (!=)
GREATER_OR_EQUAL (>=)
GREATER (>)
Comparators
-----------------------------
BinaryComparator --> lexicographically compares against the specified byte array
using the Bytes.compareTo(byte[], byte[]) method.
BinaryPrefixComparator --> lexicographically compares against a specified byte
array. It only compares up to the length of this byte array.
RegexStringComparator --> compares against the specified byte array using the given
regular expression. Only EQUAL and NOT_EQUAL comparisons are valid with this
comparator.
Examples
-----------------------------
Example1: >, 'binary:abc' will match everything that is lexicographically greater
than "abc"
Example3: !=, 'regexstring:ab*yz' will match everything that doesn't begin with
"ab" and ends with "yz"
============================================================================
HBase NameSpace Examples
============================================================================
#Create a namespace
create_namespace 'my_ns'
#drop namespace
drop_namespace 'my_ns'
#alter namespace
alter_namespace 'my_ns', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'}
tables = list('t.*')
------------------------------------------------
HBASE REST SERVICE COMMANDS
------------------------------------------------
# Foreground
$HBASE_HOME/bin/hbase rest start -p <port>
Cluster Information
------------------------
HBase Version
http://localhost:8080/version/cluster
Cluster Status
http://localhost:8080/status/cluster
Table List
http://localhost:8080/