您好,登錄后才能下訂單哦!
小編給大家分享一下HBase Shell命令怎么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
HBase Shell
1. Hbase版本查看
hbase(main):008:0> version 2.2.3, r6a830d87542b766bd3dc4cfdee28655f62de3974, 2020年 01月 10日 星期五 18:27:51 CST Took 0.0002 seconds
2. Hbase狀態查看命令shell
hbase(main):009:0> status1 active master, 0 backup masters, 1 servers, 0 dead, 3.0000 average load Took 0.0387 seconds
1. 新建表test 設置兩個列族為cf1,cf2
hbase(main):010:0> create 'test','cf1','cf2'Created table testTook 1.3418 seconds => Hbase::Table - test
2. 獲取表的描述
hbase(main):011:0> describe 'test'Table test is ENABLED test COLUMN FAMILIES DESCRIPTION {NAME => 'cf1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_B EHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false ', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICA TION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEM ORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'fa lse', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} {NAME => 'cf2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_B EHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false ', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICA TION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEM ORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'fa lse', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} 2 row(s) QUOTAS 0 row(s)Took 16.3063 seconds
3. 刪除一個列族cf2
hbase(main):012:0> alter 'test', {NAME=>'cf2',METHOD=>'delete'}Updating all regions with the new schema...1/1 regions updated. Done. Took 2.0665 seconds
4. 列出所有Hbase里的表
hbase(main):013:0> list TABLE table test 2 row(s)Took 0.0044 seconds => ["table", "test"]
5. 查詢表是否存在
hbase(main):014:0> exists 'test'Table test does exist Took 0.0224 seconds => true
6. 查詢表是否可用
hbase(main):015:0> is_enabled 'test'true Took 0.0053 seconds => true
7. 刪除一個表
hbase(main):017:0> disable 'test'Took 0.4657 seconds hbase(main):018:0> drop 'test'Took 0.2485 seconds
1. 插入數據
給Hbase的test表的row1行 插入兩個列。
hbase(main):034:0> put 'test','row1','cf1:name','tom'Took 0.0080 seconds hbase(main):035:0> put 'test','row1','cf1:age','18'Took 0.0043 seconds
列族cf1 定義了兩個列 name 和 age
2. 讀取數據
讀取test 表的row1行的所有數據
hbase(main):036:0> get 'test','row1'COLUMN CELL cf1:age timestamp=1581128757386, value=18 cf1:name timestamp=1581128743387, value=tom 1 row(s)Took 0.0264 seconds
讀取test row1行,列族cf1所有數據
hbase(main):037:0> get 'test','row1','cf1'COLUMN CELL cf1:age timestamp=1581128757386, value=18 cf1:name timestamp=1581128743387, value=tom 1 row(s)Took 0.0083 seconds
3. 更新一條記錄
Hbase的更新語法和插入新數據語法一樣
hbase(main):038:0> put 'test','row1','cf1:age','19'Took 0.0059 seconds
查看更新結果
hbase(main):039:0> get 'test','row1','cf1:age'COLUMN CELL cf1:age timestamp=1581130589721, value=19 1 row(s)Took 0.0133 seconds
4. 通過時間戳讀取兩個版本的數據
hbase(main):005:0> get 'test','row1',{COLUMN=>'cf1:age',TIMESTAMP=>1581130589721}COLUMN CELL cf1:age timestamp=1581130589721, value=19 1 row(s)Took 0.0082 seconds hbase(main):008:0> get 'test','row1',{COLUMN=>'cf1:age',TIMESTAMP=>1581128757386}COLUMN CELL cf1:age timestamp=1581128757386, value=18 1 row(s)Took 0.0135 seconds
5. 全表掃描
hbase(main):009:0> scan 'test'ROW COLUMN+CELL row1 column=cf1:age, timestamp=1581130589721, value=19 row1 column=cf1:name, timestamp=1581128743387, value=tom 1 row(s)Took 0.0107 seconds
6.統計表中行數
hbase(main):017:0> count 'test'1 row(s)Took 0.0635 seconds => 1
7. 刪除一列
hbase(main):011:0> delete 'test','row1','cf1:age'Took 0.0269 seconds
檢查刪除的結果,年齡回到了18,把19那條刪除了
hbase(main):012:0> get 'test','row1'COLUMN CELL cf1:age timestamp=1581128757386, value=18 cf1:name timestamp=1581128743387, value=tom 1 row(s)Took 0.0114 seconds
再次刪除
hbase(main):015:0> delete 'test','row1','cf1:age'Took 0.0030 seconds hbase(main):014:0> get 'test','row1'COLUMN CELL cf1:name timestamp=1581128743387, value=tom 1 row(s)Took 0.0134 seconds
8. 刪除所有的單元格
hbase(main):020:0> deleteall 'test','row1'Took 0.0041 seconds
9. 清空表所有數據
hbase(main):022:0> truncate 'test'Truncating 'test' table (it may take a while): Disabling table... Truncating table... Took 1.5547 seconds
以上是“HBase Shell命令怎么用”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。