HBase 常用運(yùn)維命令

進(jìn)入console

$ hbase shell

表的管理

1. 查看表

hbase> list

2. 創(chuàng)建表

# syntax: create <table>, {NAME => <family>, VERSIONS => <version>}
hbase> create 't1', {NAME => 'f1'}, NAME => 'f2', VERSION => 2}

3. 刪除表

需要先disable

hbase> disable 't1'
hbase> drop 't1'

4. 查看表結(jié)構(gòu)

hbase> describe 't1'

5. 修改表結(jié)構(gòu)

需要先disable

# syntax: alter <table>, {NAME => <family>, <property> => <value>}
hbase> disable 't1'
hbase> alter 't1', {NAME => 'f1', TTL => '3600'}
hbase> enable 't1'

權(quán)限管理

1. 分配權(quán)限

# syntax: grant <user>, <permission>, <table>, <column family>, <column qualifier>
# permission: "RWXCA"
# READ('R'), WRITE('W'), EXEC('X'), CREATE('C'), ADMIN('A')
hbase> grant 'u1', 'RW', 't1'

2. 查看權(quán)限

hbase> user_permission 't1'

3. 收回權(quán)限

hbase> revoke 'u1', 't1'

數(shù)據(jù)操作

1. 添加數(shù)據(jù)

# syntax: put <table>, <rowkey>, <family:column>, <value>, <timestamp>
hbase> put 't1', 'rk1', 'f1:col1', 'value1'

2. 查詢數(shù)據(jù)

查詢某條數(shù)據(jù)

# syntax: get <table>, <rowkey>, [<family:column>, ...]
hbase> get 't1', 'rk1', 'f1:col1'
hbase> get 't1', 'rk1', {COLUMN => 'f1:col1'}
hbase> get 't1', 'rk1'

掃描表

# syntax: scan <table>, {COLUMN => [<family:column>, ...], LIMIT => <num>}
# 還可添加STARTROW, TIMERANGE 和FILTER 等條件
hbase> scan 't1', {LIMIT => 5}

查詢數(shù)據(jù)行數(shù)

# syntax: count <table>, {INTERVAL => <interval>, CACHE => <cacheNum>}
# INTERVAL 設(shè)置多少行顯示一次,默認(rèn)為1000;CACHE 設(shè)置每次取的緩存區(qū)大小,默認(rèn)為10
hbase> count 't1', {INTERVAL => 100, CACHE => 500}

3. 刪除數(shù)據(jù)

刪除某行的某個(gè)列值

# syntax: delete <table>, <rowkey>, <family:column>, <timestamp>
hbase> delete 't1', 'rk1', 'f1:col1'

刪除行

# syntax: deleteall <table>, <rowkey>, <family:column>, <timestamp>
hbase> deleteall 't1', 'rk1'

刪除表中的所有數(shù)據(jù)

hbase> truncate 't1'

Region 管理

1. 移動(dòng)region

# syntax: move 'encodedRegionName', 'regionServerName'
hbase> move 'fd936a7b2233f81f59dd22d9fa924af2', 'ip-10-1-1-1.abc.co,60020,1488623785036'

2. 開啟/關(guān)閉balance

# syntax: balance_switch true | false
hbase> balance_switch false

3. 手動(dòng)split

# syntax: split 'regionName', 'splitKey'

4. 手動(dòng)major compaction

# compact all regions in a table
hbase> major_compact 't1'

# Compact an entire region
hbase> major_compact 'r1'

#Compact a single column family within a region
hbase> major_compact 'r1', 'f1'
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • HBASE SHELL常用命令 標(biāo)簽: HBase Shell 1. 進(jìn)入hbase shell console ...
    walk_and_walk閱讀 12,004評(píng)論 0 7
  • 原文地址:http://www.cnblogs.com/nexiyi/p/hbase_shell.html 進(jìn)入h...
    Albert陳凱閱讀 3,074評(píng)論 0 2
  • Hbase架構(gòu)與原理 HBase是一個(gè)分布式的、面向列的開源數(shù)據(jù)庫,該技術(shù)來源于 Fay Chang所撰寫的Goo...
    全能程序猿閱讀 86,394評(píng)論 2 37
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,537評(píng)論 19 139
  • 國家電網(wǎng)公司企業(yè)標(biāo)準(zhǔn)(Q/GDW)- 面向?qū)ο蟮挠秒娦畔?shù)據(jù)交換協(xié)議 - 報(bào)批稿:20170802 前言: 排版 ...
    庭說閱讀 12,346評(píng)論 6 13

友情鏈接更多精彩內(nèi)容