hbase基本指令

scan

  1. 根據行號查詢 STARTROW, ENDROW
語法: scan [table], {STARTROW=>'row'}
hbase(main):078:0> scan 'test' ,{STARTROW=>'row2'}
hbase(main):077:0> scan 'test' ,{ENDROW=>'row2'}

  1. 全表查
語法: scan [table]
  1. 查找指定行
語法:scan [table], {COLUMNS=>['CF:column1','CF:column2']}

get

語法:get [table], [row], [CF:column]
示例:
hbase(main):081:0* get 'test', 'row1','cf:name'

hbase(main):082:0> get 'test', 'row1'

delete

hbase 一行中的列是離散分佈的; 單元格是hbase 最小緯度定義

刪除單元格

語法: delete [table], [row], [cf:column]

刪除行

語法:
deleteall [table], [row]

disable 表

hbase 表示不可以說刪除就刪除的, 因爲有可能有很多的客戶端正在使用,或者是hbase正在做合併或者是分裂操作.
如果刪除了表就造成了無法恢復的錯誤, 所以在刪除之前需要對錶進行disable,停用下線

disable [table]

判斷是否停用: is_disabled [table]

drop

刪除表,再刪除之前需要disable

drop [table]

status

語法: status [參數]

查看集羣狀態, 有三種可選參數 
- simple
- summary (默認)
- detailed

version

查看當前版本

whoami

查看當前登錄用戶

list

查詢所有的表,支持通配符

list '[]*'

alter

建立/修改列族

傳入新的列族名稱,就是創建,傳入已存在的列族名稱,就是修改列族屬性

語法: alter [table], NAME=>[CF], [ATTR]=>[value]

示例:
   修改列族,支持的最大版本數量

# 修改前
hbase(main):030:0* desc 'test'
Table test is ENABLED                                               
test                                                                
COLUMN FAMILIES DESCRIPTION                                             
{NAME => 'cf', VERSIONS => '5'

# 修改

hbase(main):033:0* alter 'test', NAME=>'cf', VERSIONS=>10
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.2514 seconds          

# 驗證
hbase(main):036:0* desc 'test'
Table test is ENABLED                                                 
test                                                     
COLUMN FAMILIES DESCRIPTION                       
{NAME => 'cf', VERSIONS => '10',

建立/修改多個列族

語法: alter [table], {NAME=>'列族1', 屬性名1=>屬性值1,,..}, {NAME=>'列族2', 屬性名1=>屬性值1}
# 創建兩個列族,最大版數量分別是 3,4
hbase(main):033:0* alter 'test', {NAME=>'cf3',VERSIONS=>3}, {NAME=>'cf4', VERSIONS=>4}
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.5052 seconds                                                 
hbase(main):062:0> desc 'test'

刪除列族

列族刪除:

語法: alter '表名', 'delete'=>'列族名'

示例:

hbase(main):066:0* alter 'test', 'delete'=>'cf4'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.4025 seconds       

修改表級別屬性

//TODO

設置表配置

//TODO

刪除表級別屬性

//TODO

create

  1. 創建表,創建表的同時可以修改表的屬性
語法: 
create '表名', {NAME=>'列族名1', 屬性名1=>屬性值1}, {NAME=>'列族名2', 屬性名1=>屬性值1}

示例:

hbase(main):070:0* create 'test1',{NAME=>'cf', VERSIONS=>3},{NAME=>'cf1', VERSIONS=>3},{NAME=>'cf2', VERSIONS=>4}
Created table test1
Took 1.3587 seconds                                                                                          
=> Hbase::Table - test1
  1. 創建表,不指定列族屬性
語法: 
create '表名','列族1','列族2'..

describe

輸出表的描述信息
describe [table]
或者
desc [table]

alter_status

查看錶的各個region的更新情況,這條命令在異步更新表的時候,用來查看更改
命令執行的情況,判斷該命令是否執行完畢

語法:
 alter_status '表名'
示例:

alter_status 'test1'
1/1 regions updated.
Done.
Took 1.0209 seconds    

alter_async

異步更新表。使用這個命令不需要等待表的全表region更新完成就返回.

語法:
alter_aynch '表名', 參數列表
示例:
alter_async 'test1', NAME=>'cf', VERSIONS=>5
Took 1.1535 seconds            
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章