1.進入HBase Shell 命令:
$ ${HBASE_HOME}/bin/hbase shell
2.獲得命令列表:
hbase> help
3.alter:
1) 表't1'中,增加或修改一個column family=> 'f1'並保持其最大版本數為5:
hbase> alter 't1', {NAME => 'f1', VERSIONS => 5}
2)刪除表't1'中值為'f1'的column family:
hbase> alter 't1', {NAME => 'f1', METHOD => 'delete'}
3)你也可以修改表屬性,比如:MAX_FILESIZE,MEMSTORE_FLUSHSIZE和READONLY:
hbase> alter 't1', {METHOD => 'table_att', MAX_FILESIZE => '134217728'}
4.count:
返回表的全部行數,這種操作會花費很長時間(run counting mapreduce job),默認每1000行顯示一次,當然這個是可以自己配置的。
hbase> count 't1'
hbase> count 't1', 100000
5.create:
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, \
BLOCKCACHE => true}
TTL為此column family的生命周期,單位為秒。
6.describe:
獲得表的屬性。
hbase> describe 't1'
7.delete:
刪除一個cell,需要用timestamp定位。
hbase> delete 't1', 'r1', 'f1:c1', ts1
8.deleteall
根據指定條件批量刪除cell。
hbase> deleteall 't1', 'r1'
hbase> deleteall 't1', 'r1', 'f1:c1'
hbase> deleteall 't1', 'r1', 'f1:c1', ts1
9.disable
使一個指定表失效。
hbase> exists 't1'
10.drop
刪除一張表,在刪除之前必須先disable此表,如果這個表有多個region,先運行:
hbase> major_compact ".META."
11.enable
與disable相對應。
12.exists
判斷表是否存在。
hbase> exists 't1'
13.exit
離開hbase shell。
14.get
根據指定條件返回查詢結果,必須指定row。
hbase> get 't1', 'r1' hbase> get 't1', 'r1', {COLUMN => 'f1:c1'} hbase> get 't1', 'r1', {COLUMN => ['f1:c1', 'f1:c2', 'f1:c3']} hbase> get 't1', 'r1', {COLUMN => 'f1:c1', TIMESTAMP => ts1} hbase> get 't1', 'r1', {COLUMN => 'f1:c1', TIMESTAMP => ts1, \ VERSIONS => 4}
15.list
獲得hbase中所有表名。
16.put
新增一個cell。
hbase> put 't1', 'r1', 'f1:c1', 'value', ts1
17.tools
獲得server端的一些操作命令,如close_regin,flush等,如以后遇到,會另作具體詳解。
18.scan
根據指定條件掃描指定表,條件包括LIMIT,STARTROW,STOPROW,TIMESTAMP,COLUMNS。如果在COLUMNS中未指定具體column family則會掃描全部column family。
hbase> scan '.META.' hbase> scan '.META.', {COLUMNS => 'info:regioninfo'} hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, \ STARTROW => 'xyz'}
在掃描的時候也可以自動設置緩存的開啟和關閉狀態,默認為開啟。
hbase> scan 't1', {COLUMNS => ['c1', 'c2'], CACHE_BLOCKS => false}
19.status
顯示hbase中列簇狀態,條件可以為:summary,simple,detailed,默認為summary。
hbase> status hbase> status 'simple' hbase> status 'summary'
hbase> status 'detailed'
20.shutdown,truncate,version