help ‘status’
hbase(main):006:0> help 'status'
Show cluster status. Can be 'summary', 'simple', 'detailed', or 'replication'. The
default is 'summary'. Examples:
hbase> status
hbase> status 'simple'
hbase> status 'summary'
hbase> status 'detailed'
hbase> status 'replication'
hbase> status 'replication', 'source'
hbase> status 'replication', 'sink'
status
hbase(main):007:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 7.0000 average load
list
hbase(main):008:0> list
TABLE
student
course
member
5 row(s) in 0.0710 seconds
=> ["course", "student","member"]
create ‘FileTable’,‘fileInfo’,‘saveInfo’
hbase(main):001:0> create 'man','basic','extend'
0 row(s) in 2.7520 seconds
=> Hbase::Table - man
describe ‘FileTable’
hbase(main):002:0> describe 'man'
Table man is ENABLED
man
COLUMN FAMILIES DESCRIPTION
{NAME => 'basic', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => '
FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'extend', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL =>
'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
2 row(s) in 0.1980 seconds
alter ‘FileTable’, ‘cf’
hbase(main):003:0> alter 'man','cf'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.0370 seconds
注意:最好不要修改列簇,因为涉及到物理存储更新,所以最好在建表的时候,指定好表结构,之后尽量不要去修改。可以看到当添加一个列簇的时候,执行了update all region操作。
alter ‘man’, {NAME => ‘cf’, METHOD => ‘delete’}
hbase(main):014:0> alter 'man',{NAME=>'cf',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.3180 seconds
注意:NAME 和 METHOD必须为大写,这事规定。
hbase(main):004:0> put 'man', 'rowkey1','basic:name','zs'
0 row(s) in 0.1850 seconds
hbase(main):005:0> put 'man', 'rowkey1','basic:age','18'
0 row(s) in 0.0090 seconds
hbase(main):006:0> put 'man', 'rowkey1','basic:sex','male'
0 row(s) in 0.0100 seconds
hbase(main):007:0> put 'man', 'rowkey1','extend:salary','0'
0 row(s) in 0.0080 seconds
hbase(main):008:0> put 'man', 'rowkey1','extend:job','student'
0 row(s) in 0.0080 seconds
hbase(main):009:0> put 'man', 'rowkey2','basic:name','jack'
0 row(s) in 0.0070 seconds
hbase(main):010:0> put 'man', 'rowkey2','basic:age','26'
0 row(s) in 0.0080 seconds
hbase(main):011:0> put 'man', 'rowkey2','basic:sex','male'
0 row(s) in 0.0100 seconds
hbase(main):012:0> put 'man', 'rowkey2','extend:job','IT'
0 row(s) in 0.0110 seconds
hbase(main):013:0> put 'man', 'rowkey2','extend:salary','20000'
0 row(s) in 0.0130 seconds
count ‘man’
hbase(main):025:0> count 'FileTable'
2 row(s) in 0.0450 seconds
get ‘man’, ‘rowkey1’
hbase(main):015:0> get 'man','rowkey1'
COLUMN CELL
basic:age timestamp=1541177216436, value=18
basic:name timestamp=1541177216371, value=zs
basic:sex timestamp=1541177216528, value=male
extend:job timestamp=1541177216611, value=student
extend:salary timestamp=1541177216569, value=0
5 row(s) in 0.0250 seconds
get ‘man’, ‘rowkey1’, ‘basic’
hbase(main):017:0> get 'man','rowkey1','basic'
COLUMN CELL
basic:age timestamp=1541177216436, value=18
basic:name timestamp=1541177216371, value=zs
basic:sex timestamp=1541177216528, value=male
3 row(s) in 0.0200 seconds
scan ‘man’
hbase(main):019:0> scan 'man'
ROW COLUMN+CELL
rowkey1 column=basic:age, timestamp=1541177216436, value=18
rowkey1 column=basic:name, timestamp=1541177216371, value=zs
rowkey1 column=basic:sex, timestamp=1541177216528, value=male
rowkey1 column=extend:job, timestamp=1541177216611, value=student
rowkey1 column=extend:salary, timestamp=1541177216569, value=0
rowkey2 column=basic:age, timestamp=1541177216697, value=26
rowkey2 column=basic:name, timestamp=1541177216655, value=jack
rowkey2 column=basic:sex, timestamp=1541177216726, value=male
rowkey2 column=extend:job, timestamp=1541177216759, value=IT
rowkey2 column=extend:salary, timestamp=1541177217293, value=20000
2 row(s) in 0.0580 seconds
scan ‘man’, {COLUMN=>‘basic’}
hbase(main):020:0> scan 'man', {COLUMN=>'basic'}
ROW COLUMN+CELL
rowkey1 column=basic:age, timestamp=1541177216436, value=18
rowkey1 column=basic:name, timestamp=1541177216371, value=zs
rowkey1 column=basic:sex, timestamp=1541177216528, value=male
rowkey2 column=basic:age, timestamp=1541177216697, value=26
rowkey2 column=basic:name, timestamp=1541177216655, value=jack
rowkey2 column=basic:sex, timestamp=1541177216726, value=male
2 row(s) in 0.0500 seconds
scan ‘man’, {COLUMNS=> ‘basic:name’}
hbase(main):021:0> scan 'man', {COLUMNS=> 'basic:name'}
ROW COLUMN+CELL
rowkey1 column=basic:name, timestamp=1541177216371, value=zs
rowkey2 column=basic:name, timestamp=1541177216655, value=jack
2 row(s) in 0.0280 seconds
hbase(main):022:0> scan 'man',{STARTROW=>'rowkey1',LIMIT=>1,VERSION=>1}
ROW COLUMN+CELL
rowkey1 column=basic:age, timestamp=1541177216436, value=18
rowkey1 column=basic:name, timestamp=1541177216371, value=zs
rowkey1 column=basic:sex, timestamp=1541177216528, value=male
rowkey1 column=extend:job, timestamp=1541177216611, value=student
rowkey1 column=extend:salary, timestamp=1541177216569, value=0
1 row(s) in 0.0190 seconds
scan ‘man’, FILTER=>“ValueFilter(=,'name:zs’)”
scan ‘man’, FILTER=>“ColumnPrefixFilter(‘sex’) AND ValueFilter ValueFilter(=,‘substring:10’)”
delete ‘man’,‘rowkey1’,‘basic:age’
get ‘man’,‘rowkey1’,‘basic:age’
hbase(main):025:0> delete 'man','rowkey1','basic:age'
0 row(s) in 0.0380 seconds
hbase(main):026:0>
hbase(main):027:0* get 'man','rowkey1','basic:age'
COLUMN CELL
0 row(s) in 0.0140 seconds
deleteall ‘man’,‘rowkey1’
get ‘man’,’rowkey1’
hbase(main):017:0> deleteall 'man','rowkey1'
0 row(s) in 0.0130 seconds
hbase(main):018:0> get 'man','rowkey1'
COLUMN CELL
0 row(s) in 0.0040 seconds
注意:这里根据rowkey删除,需要使用deleteall
is_enabled ‘man’
is_disabled ‘man’
hbase(main):020:0> is_enabled 'man'
true
0 row(s) in 0.0990 seconds
hbase(main):021:0> is_disabled 'man'
false
0 row(s) in 0.0240 seconds
disable ‘man’
drop ‘man’
hbase(main):029:0> disable 'man'
0 row(s) in 2.4430 seconds
hbase(main):030:0> drop 'man'
0 row(s) in 1.3180 seconds
exists ‘FileTable’
hbase(main):028:0> exists 'man'
Table man does exist
0 row(s) in 0.0340 seconds