HBase shell詳細操作指南
進入hbase Shell
[root@test31 ~]# hbase shell
HBase Shell; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
1.檢視伺服器狀態
hbase(main):001:0> status
1 servers, 0 dead, 3.0000 average load
2.檢視HBase版本
hbase(main):002:0> version
0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
3.DDL操作
1).create命令
建立一個具有三個列族"member_id"和"address"即"info"的表"member",其中表名、行和列都要用單引號括起來,並以逗號隔開。
hbase(main):003:0> create 'member','member_id','address','info'
0 row(s) in 1.1770 seconds
2).list命令
檢視當前HBase中具有哪些表
hbase(main):004:0> list
TABLE
member
test
2 row(s) in 0.0170 seconds
3).describe 命令
檢視錶的描述資訊
hbase(main):006:0> describe 'member'
DESCRIPTION ENABLED
{NAME => 'member', FAMILIES => [{NAME => 'address', BLOOMFILTER => 'NONE', REPLICATION_SCO true
PE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647
', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'info', BLO
OMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_
VERSIONS => '0', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCAC
HE => 'true'}, {NAME => 'member_id', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERS
IONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', BLOCKSIZE =>
'65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0320 seconds
4).刪除一個列族:disable,alter,enable
修改表結構必須先disable
hbase(main):004:0> disable member
NameError: undefined local variable or method `member' for #
hbase(main):005:0> disable 'member'
0 row(s) in 2.1560 seconds
刪除member表的info列
hbase(main):006:0> alter 'member', 'delete' => 'info'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.3370 seconds
記得enable表:
hbase(main):009:0> enable 'member'
0 row(s) in 2.2330 seconds
5).刪除一個表test(disable,drop)
hbase(main):025:0> disable 'test'
0 row(s) in 2.2100 seconds
hbase(main):026:0> drop 'test'
0 row(s) in 1.2350 seconds
6).查詢表是否存在
hbase(main):033:0> exists 'test'
Table test does not exist
0 row(s) in 0.1820 seconds
7).檢視錶是否enable
hbase(main):032:0> is_enabled 'member'
true
0 row(s) in 0.0070 seconds
4.DML操作
1).插入資料
hbase(main):005:0> put 'member','scutshuxue','info:age','24'
0 row(s) in 0.0790 seconds
hbase(main):005:0> put 'member','duansf','info:age','37'
0 row(s) in 0.0790 seconds
hbase(main):001:0> put 'member','scutshuxue','info:company','alibaba'
0 row(s) in 0.6520 seconds
hbase(main):002:0> put 'member','xiaofeng','address:contry','china'
0 row(s) in 0.0090 seconds
hbase(main):007:0> put 'member','xiaofeng','info:birthday','1987-4-17'
0 row(s) in 0.0120 seconds
注:插入語句後面一定不要有空格。
2).獲取一條資料
hbase(main):012:0* get 'member','xiaofeng'
COLUMN CELL
address:contry timestamp=1488307463293, value=china
info:birthday timestamp=1488307533852, value=1987-4-17
2 row(s) in 0.0130 seconds
3).獲取一條記錄中某個列族的資訊
hbase(main):013:0> get 'member','xiaofeng','info'
COLUMN CELL
info:birthday timestamp=1488307533852, value=1987-4-17
1 row(s) in 0.0100 seconds
4).獲取一條記錄的某個列族中的某個列的資訊
hbase(main):020:0> get 'member','xiaofeng','info:birthday'
COLUMN CELL
info:birthday timestamp=1488307533852, value=1987-4-17
1 row(s) in 0.0090 seconds
5).更新一條記錄
把duansf的年齡改為38歲
hbase(main):022:0* get 'member','duansf','info:age'
COLUMN CELL
info:age timestamp=1488308172957, value=37
1 row(s) in 0.0090 seconds
put 'member','duansf','info:age','38'
6).刪除member表中某個列
hbase(main):032:0* delete 'member','scutshuxue','info:age'
0 row(s) in 0.0080 seconds
7).member表全表掃描(類似於關係型資料庫select *)
hbase(main):002:0> scan 'member'
ROW COLUMN+CELL
scutshuxue column=info:age, timestamp=1488306890710, value=24
scutshuxue column=info:company, timestamp=1488307003752, value=alibaba
xiaofeng column=address:contry, timestamp=1488307463293, value=china
xiaofeng column=info:birthday, timestamp=1488307533852, value=1987-4-17
2 row(s) in 0.9780 seconds
8).刪除整行
hbase(main):036:0> deleteall 'member','scutshuxue'
0 row(s) in 0.0090 seconds
9).查詢member表中有多少行
hbase(main):041:0> count 'member'
2 row(s) in 0.0240 seconds
10).清空整張表
hbase(main):045:0* truncate 'member'
Truncating 'member' table (it may take a while):
- Disabling table...
- Dropping table...
- Creating table...
0 row(s) in 4.8640 seconds
附圖:
HBase Shell命令解釋
[root@test31 ~]# hbase shell
HBase Shell; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
1.檢視伺服器狀態
hbase(main):001:0> status
1 servers, 0 dead, 3.0000 average load
2.檢視HBase版本
hbase(main):002:0> version
0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
3.DDL操作
1).create命令
建立一個具有三個列族"member_id"和"address"即"info"的表"member",其中表名、行和列都要用單引號括起來,並以逗號隔開。
hbase(main):003:0> create 'member','member_id','address','info'
0 row(s) in 1.1770 seconds
2).list命令
檢視當前HBase中具有哪些表
hbase(main):004:0> list
TABLE
member
test
2 row(s) in 0.0170 seconds
3).describe 命令
檢視錶的描述資訊
hbase(main):006:0> describe 'member'
DESCRIPTION ENABLED
{NAME => 'member', FAMILIES => [{NAME => 'address', BLOOMFILTER => 'NONE', REPLICATION_SCO true
PE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647
', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'info', BLO
OMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_
VERSIONS => '0', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCAC
HE => 'true'}, {NAME => 'member_id', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERS
IONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', BLOCKSIZE =>
'65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0320 seconds
4).刪除一個列族:disable,alter,enable
修改表結構必須先disable
hbase(main):004:0> disable member
NameError: undefined local variable or method `member' for #
hbase(main):005:0> disable 'member'
0 row(s) in 2.1560 seconds
刪除member表的info列
hbase(main):006:0> alter 'member', 'delete' => 'info'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.3370 seconds
記得enable表:
hbase(main):009:0> enable 'member'
0 row(s) in 2.2330 seconds
5).刪除一個表test(disable,drop)
hbase(main):025:0> disable 'test'
0 row(s) in 2.2100 seconds
hbase(main):026:0> drop 'test'
0 row(s) in 1.2350 seconds
6).查詢表是否存在
hbase(main):033:0> exists 'test'
Table test does not exist
0 row(s) in 0.1820 seconds
7).檢視錶是否enable
hbase(main):032:0> is_enabled 'member'
true
0 row(s) in 0.0070 seconds
4.DML操作
1).插入資料
hbase(main):005:0> put 'member','scutshuxue','info:age','24'
0 row(s) in 0.0790 seconds
hbase(main):005:0> put 'member','duansf','info:age','37'
0 row(s) in 0.0790 seconds
hbase(main):001:0> put 'member','scutshuxue','info:company','alibaba'
0 row(s) in 0.6520 seconds
hbase(main):002:0> put 'member','xiaofeng','address:contry','china'
0 row(s) in 0.0090 seconds
hbase(main):007:0> put 'member','xiaofeng','info:birthday','1987-4-17'
0 row(s) in 0.0120 seconds
注:插入語句後面一定不要有空格。
2).獲取一條資料
hbase(main):012:0* get 'member','xiaofeng'
COLUMN CELL
address:contry timestamp=1488307463293, value=china
info:birthday timestamp=1488307533852, value=1987-4-17
2 row(s) in 0.0130 seconds
3).獲取一條記錄中某個列族的資訊
hbase(main):013:0> get 'member','xiaofeng','info'
COLUMN CELL
info:birthday timestamp=1488307533852, value=1987-4-17
1 row(s) in 0.0100 seconds
4).獲取一條記錄的某個列族中的某個列的資訊
hbase(main):020:0> get 'member','xiaofeng','info:birthday'
COLUMN CELL
info:birthday timestamp=1488307533852, value=1987-4-17
1 row(s) in 0.0090 seconds
5).更新一條記錄
把duansf的年齡改為38歲
hbase(main):022:0* get 'member','duansf','info:age'
COLUMN CELL
info:age timestamp=1488308172957, value=37
1 row(s) in 0.0090 seconds
put 'member','duansf','info:age','38'
6).刪除member表中某個列
hbase(main):032:0* delete 'member','scutshuxue','info:age'
0 row(s) in 0.0080 seconds
7).member表全表掃描(類似於關係型資料庫select *)
hbase(main):002:0> scan 'member'
ROW COLUMN+CELL
scutshuxue column=info:age, timestamp=1488306890710, value=24
scutshuxue column=info:company, timestamp=1488307003752, value=alibaba
xiaofeng column=address:contry, timestamp=1488307463293, value=china
xiaofeng column=info:birthday, timestamp=1488307533852, value=1987-4-17
2 row(s) in 0.9780 seconds
8).刪除整行
hbase(main):036:0> deleteall 'member','scutshuxue'
0 row(s) in 0.0090 seconds
9).查詢member表中有多少行
hbase(main):041:0> count 'member'
2 row(s) in 0.0240 seconds
10).清空整張表
hbase(main):045:0* truncate 'member'
Truncating 'member' table (it may take a while):
- Disabling table...
- Dropping table...
- Creating table...
0 row(s) in 4.8640 seconds
附圖:
HBase Shell命令解釋
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2134477/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Hbase shell的基本操作
- hbase之hbase shell
- hbase shell命令
- HBase 系列(五)——HBase常用 Shell 命令
- Azkaban詳細操作
- 超詳細Python正規表示式操作指南(re使用),一Python
- Hbase(二)Hbase常用操作
- Git 操作命令詳細Git
- shell 正規表示式詳細整理
- shell程式設計-sed命令詳解(超詳細)程式設計
- HBase 基本操作
- java中cookie操作詳細JavaCookie
- hbase - [03] 客戶端常用命令(hbase shell)客戶端
- Android O 適配詳細指南Android
- linux shell 指令碼語言教程(超詳細!)Linux指令碼
- Python:檔案操作詳細教程Python
- 超詳細的 Vagrant 上手指南
- Electron 的初學者詳細指南
- Stable Diffusion WebUI詳細使用指南WebUI
- Kubernetes 部署 - DevOps CI/CD詳細指南dev
- 操作指南|最詳盡文件翻譯志願指南
- 反編譯Android APK詳細操作指南[ApkTool,dex2jar,JD-GUI](Mac)編譯AndroidAPKJARGUIMac
- mysql之行(記錄)的詳細操作MySql
- 抖音文案號操作詳細教程
- 超詳細Maven技術應用指南Maven
- 資料庫索引:綜合詳細指南資料庫索引
- 前端介面神器之 Json Server 詳細指南前端JSONServer
- 保姆級教程!玩轉 ChunJun 詳細指南
- hbase與phoenix整合(使用phoenix操作hbase資料)
- HBase Replication詳解
- HBase Shell 十大花式玩兒法
- MyBatis的逆向工程詳細步驟操作MyBatis
- Linux 目錄結構及詳細操作Linux
- Linux 檔案屬性及詳細操作Linux
- 使用 createError 建立錯誤物件的詳細指南Error物件
- Hadoop(四)C#操作HbaseHadoopC#
- HBase權威指南【中文版】
- winscp操作說明,winscp操作說明的詳細解讀
- HBase-Region詳解