1. Group name: general
1) status: 查看hbase中master状态
hbase(main):004:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 27.0000 average load
2) version: 查看hbase版本
hbase(main):005:0> version
1.3.0, re359c76e8d9fd0d67396456f92bcbad9ecd7a710, Tue Jan 3 05:31:38 MSK 2017
3) whoami: 查看当前用户
hbase(main):006:0> whoami
llh (auth:SIMPLE)
groups: llh, adm, cdrom, sudo, dip, plugdev, lpadmin, sambashare
2. Group name: namespace
1) create_namespace: 创建命名空间
hbase(main):010:0> create_namespace 'test'
0 row(s) in 1.0160 seconds
2) drop_namespace: 删除命名空间
hbase(main):011:0> drop_namespace 'test'
0 row(s) in 0.8820 seconds
3) list_namespace: 显示所有命名空间
hbase(main):012:0> list_namespace
NAMESPACE
default
hbase
2 row(s) in 0.0080 seconds
4) describe_namespace: 显示单个命名空间的详细信息
hbase(main):013:0> describe_namespace 'hbase'
DESCRIPTION
{NAME => 'hbase'}
1 row(s) in 0.0060 seconds
3. Group name: ddl
1) create: 创建单个表
hbase(main):002:0> create 'tb','cf1'
0 row(s) in 1.3180 seconds
=> Hbase::Table - tb
hbase(main):005:0> create 'test:tb1','cf1'
0 row(s) in 1.2320 seconds
=> Hbase::Table - test:tb1
2) list: 显示所有表
hbase(main):009:0> list
TABLE
test:tb1
tb
2 row(s) in 0.0420 seconds
=> ["tb", "test:tb1"]
3) describe: 显示单个表的详细信息
hbase(main):010:0> describe 'test:tb1'
Table test:tb1 is ENABLED
test:tb1
COLUMN FAMILIES DESCRIPTION
{NAME => 'cf1', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEE
P_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COM
PRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '655
36', REPLICATION_SCOPE => '0'}
1 row(s) in 0.1440 seconds
4) disable: 关闭单个表
hbase(main):011:0> disable 'test:tb1'
0 row(s) in 2.2720 seconds
5) enable: 开启单个表
hbase(main):012:0> enable 'test:tb1'
0 row(s) in 1.2620 seconds
6) drop: 删除单个表
hbase(main):014:0> disable 'tb'
0 row(s) in 2.2450 seconds
hbase(main):015:0> drop 'tb'
0 row(s) in 1.2630 seconds
7) alter: 修改表结构
hbase(main):016:0> alter 'test:tb1', NAME=>'cf1', TTL=>'3600' //修改列簇为cf1数据保留两个小时
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.9330 seconds
hbase(main):017:0> alter 'test:tb1', NAME=>'cf2', VERSIONS=>5 //改变或添加一个列簇
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.8890 seconds
hbase(main):019:0> alter 'test:tb1', NAME=>'cf2', METHOD=>'delete' //删除一个列簇
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.1470 seconds
8) alter_async: 异步执行alter
9) alter_status: 查看alter执行的状态
hbase(main):026:0> alter_status 'test:tb1'
1/1 regions updated.
Done.
10) is_enabled: 验证指定表是否有效
hbase(main):020:0> is_enabled 'test:tb1'
true
0 row(s) in 0.0150 seconds
11) exists: 查看指定表是否存在
hbase(main):021:0> exists 'test:tb1'
Table test:tb1 does exist
0 row(s) in 0.0080 seconds
12) locate_region: 查看region分布情况
hbase(main):022:0> locate_region 'test:tb1','cf1'
HOST REGION
ebi-llh:16020 {ENCODED => 5f4d2d31db8eaaeb39cfd978b0234054, NAME => 'tes
t:tb1,,1521473386612.5f4d2d31db8eaaeb39cfd978b0234054.', S
TARTKEY => '', ENDKEY => ''}
1 row(s) in 0.0250 seconds
13) show_filters: 显示所有过滤器(*)
hbase(main):023:0> show_filters
DependentColumnFilter
KeyOnlyFilter
ColumnCountGetFilter
4. Group name: dml
1) put: 插入或更新数据
hbase(main):001:0> put 'test:tb1','10001','cf1:name','jack'
0 row(s) in 0.3390 seconds
2) delete: 删除单条数据
hbase(main):002:0> delete 'test:tb1','10001','cf1:name'
0 row(s) in 0.0240 seconds
3) deleteall: 删除多条数据
hbase(main):007:0> deleteall 'test:tb1','10001'
0 row(s) in 0.0070 seconds
4) get: 获取数据
hbase(main):005:0> get 'test:tb1','10001'
COLUMN CELL
cf1:age timestamp=1521942283487, value=22
cf1:name timestamp=1521942276491, value=Jack
1 row(s) in 0.0160 seconds
hbase(main):006:0> get 'test:tb1','10001','cf1:age'
COLUMN CELL
cf1:age timestamp=1521942283487, value=22
1 row(s) in 0.0130 seconds
hbase(main):007:0> get 'test:tb1','10001',{TIMERANGE=>[1521942283487,1521942283488]}
COLUMN CELL
cf1:age timestamp=1521942283487, value=22
1 row(s) in 0.0070 seconds
hbase(main):008:0> get 'test:tb1','10001',{COLUMN=>['cf1:name']} //等效于cf1:name
COLUMN CELL
cf1:name timestamp=1521942276491, value=Jack
1 row(s) in 0.0070 seconds
hbase(main):009:0> get 'test:tb1','10001',{FILTER=>"ValueFilter(=,'substring:22')"} //获取值包含22的数据
COLUMN CELL
cf1:age timestamp=1521942283487, value=22
1 row(s) in 0.0430 seconds
hbase(main):010:0> get 'test:tb1','10001',{FILTER=>"ValueFilter(=,'binary:22')"} //获取值等于22的数据
COLUMN CELL
cf1:age timestamp=1521942283487, value=22
1 row(s) in 0.0160 seconds
5) scan 扫描获取数据
hbase(main):017:0> scan 'test:tb1'
ROW COLUMN+CELL
10001 column=cf1:age, timestamp=1521942283487, value=22
10001 column=cf1:name, timestamp=1521942276491, value=Jack
1 row(s) in 0.0160 seconds
hbase(main):018:0> scan 'test:tb1',{COLUMNS=>'cf1:age'}
ROW COLUMN+CELL
10001 column=cf1:age, timestamp=1521942283487, value=22
1 row(s) in 0.0130 seconds
hbase(main):019:0> scan 'test:tb1',{COLUMNS=>'cf1:age', STARTROW=>'2', LIMIT=>1} //获取列为age,rowkey以100开始的1条数据
ROW COLUMN+CELL
0 row(s) in 0.0090 seconds
hbase(main):021:0> scan 'test:tb1',{TIMERANGE=>[1521942276491,1521942276492]} //获取插入时间戳范围为[ts1,ts2]的数据
ROW COLUMN+CELL
10001 column=cf1:name, timestamp=1521942276491, value=Jack
1 row(s) in 0.0110 seconds
hbase(main):023:0> scan 'test:tb1',{FILTER=>"PrefixFilter('100')"} //获取rowkey包含100的数据
ROW COLUMN+CELL
10001 column=cf1:age, timestamp=1521942283487, value=22
10001 column=cf1:name, timestamp=1521942276491, value=Jack
1 row(s) in 0.0100 seconds
hbase(main):024:0> scan 'test:tb1',{FILTER=>"ValueFilter(=,'substring:22')"} //获取值包含22的数据
ROW COLUMN+CELL
10001 column=cf1:age, timestamp=1521942283487, value=22
1 row(s) in 0.0090 seconds
6) count: 统计表总数(慎重使用)
hbase(main):027:0> count 'test:tb1', INTERVAL=>10, CACHE=>1000
1 row(s) in 0.0270 seconds
=> 1
7) append: 追加,假如该列不存在添加新列,存在将值追加到最后
hbase(main):028:0> append 'test:tb1','10001','cf1:name','_back' //追加,假如该列不存在添加新列,存在将值追加到最后
0 row(s) in 0.0250 seconds
hbase(main):029:0> get 'test:tb1','10001','cf1:name'
COLUMN CELL
cf1:name timestamp=1521943322296, value=Jack_back
1 row(s) in 0.0080 seconds
8) truncate: 清空表(disable-->drop-->create)
hbase(main):030:0> truncate 'test:tb1'
Truncating 'test:tb1' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 4.1460 seconds
9) truncate_preserve: 清空表但保留分区
hbase(main):031:0> truncate_preserve 'test:tb1'
Truncating 'test:tb1' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 3.3780 seconds
10) *incr: 增加指定表行或列的值(不会用)
11) *get_counter: 统计指定的行数(不会用)
5. Group name: tools
1) flush: 刷新数据
hbase(main):028:0> flush 'test:tb1'
0 row(s) in 0.2550 seconds