HBase shell命令
目錄
打錯(cuò)命令,按ctrl+Backspace
1.啟動(dòng)hbase
2.關(guān)閉hbase
3. HBase Shell
4.help命令
5.查看集群狀態(tài)status
6.創(chuàng)建表
7.插入數(shù)據(jù)
8.查詢數(shù)據(jù)
9.掃描列簇
10.掃描列簇的指定列
11.掃描指定范圍
12.查看表結(jié)構(gòu)
13.更新指定字段的數(shù)據(jù)
14.查看指定行的數(shù)據(jù)
15.查看指定列族的列的數(shù)據(jù)
16.查看行數(shù)
17.刪除某 rowkey 行鍵的全部數(shù)據(jù):
18.刪除某 rowkey 的某一列數(shù)據(jù):
19.列舉所有表list?
20.表是否存在exists
?21.啟用表enable和禁用表disable
22.清空表數(shù)據(jù)
23.刪除表
打錯(cuò)命令,按ctrl+Backspace
1.啟動(dòng)hbase
start-hbase.sh2.關(guān)閉hbase
stop-hbase.sh3. HBase Shell
是官方提供的一組命令,用于操作HBase。如果配置了HBase的環(huán)境變量了,就可以輸入hbase shell 命令進(jìn)入命令行。
hbase shell4.help命令
可以通過(guò) help '命名名稱'來(lái)查看命令行的具體使用,包括命令的作用和用法。
通過(guò)help ‘hbase’ 命名來(lái)查看hbase shell 支持的所有命令,hbase將命令進(jìn)行分組,其中ddl、dml使用較多。
5.查看集群狀態(tài)status
hbase(main):003:0> status 1 active master, 0 backup masters, 1 servers, 0 dead, 7.0000 average load6.創(chuàng)建表
#語(yǔ)法 create '表名','列簇名' #例如 hbase(main):014:0> create 'year','info' 0 row(s) in 1.2980 seconds=> Hbase::Table - year7.插入數(shù)據(jù)
#語(yǔ)法 put '表名','行鍵','列簇名','值' #例如 # 第一行數(shù)據(jù) hbase(main):015:0> put 'year', '1001', 'info:id', '1' 0 row(s) in 0.1320 secondshbase(main):016:0> put 'year', '1001', 'info:name', '張三' 0 row(s) in 0.0070 secondshbase(main):017:0> put 'year', '1001', 'info:age', '28' 0 row(s) in 0.0080 seconds # 第二行數(shù)據(jù) hbase(main):026:0> put 'year', '1002', 'info:id', '2' 0 row(s) in 0.0100 secondshbase(main):027:0> put 'year', '1002', 'info:name', '李四' 0 row(s) in 0.0050 secondshbase(main):028:0> put 'year', '1002', 'info:age', '20' 0 row(s) in 0.0040 seconds # 第三行數(shù)據(jù) hbase(main):029:0> put 'year', '1003', 'info:id', '3' 0 row(s) in 0.0120 secondshbase(main):030:0> put 'year', '1003', 'info:name', 'wangwu' 0 row(s) in 0.0070 secondshbase(main):031:0> put 'year', '1003', 'info:age', '16' 0 row(s) in 0.0140 seconds8.查詢數(shù)據(jù)
scan '表名' hbase(main):032:0> scan 'year' ROW COLUMN+CELL 1001 column=info:age, timestamp=1650518056828, value=28 1001 column=info:id, timestamp=1650518051442, value=1 1001 column=info:name, timestamp=1650518051501, value=\xE5\xBC\xA0\xE4\xB8\x89 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:id, timestamp=1650518373023, value=2 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B #中文編碼 1003 column=info:age, timestamp=1650518386062, value=16 1003 column=info:id, timestamp=1650518382621, value=3 1003 column=info:name, timestamp=1650518382650, value=wangwu 3 row(s) in 0.0430 seconds9.掃描列簇
# 語(yǔ)法 scan '表名', {COLUMN=>'列族名'} # 例如 hbase(main):033:0> scan 'year',{COLUMN=>'info'} ROW COLUMN+CELL 1001 column=info:age, timestamp=1650518056828, value=28 1001 column=info:id, timestamp=1650518051442, value=1 1001 column=info:name, timestamp=1650518051501, value=\xE5\xBC\xA0\xE4\xB8\x89 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:id, timestamp=1650518373023, value=2 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B 1003 column=info:age, timestamp=1650518386062, value=16 1003 column=info:id, timestamp=1650518382621, value=3 1003 column=info:name, timestamp=1650518382650, value=wangwu 3 row(s) in 0.0360 seconds10.掃描列簇的指定列
# 語(yǔ)法 scan '表名', {COLUMN=>'列族名:列名'} #例如 hbase(main):034:0> scan 'year',{COLUMN=>'info:age'} ROW COLUMN+CELL 1001 column=info:age, timestamp=1650518056828, value=28 1002 column=info:age, timestamp=1650518373828, value=20 1003 column=info:age, timestamp=1650518386062, value=16 3 row(s) in 0.0310 seconds11.掃描指定范圍
hbase(main):035:0> scan 'year',{STARTROW => '1001', STOPROW => '1003'} #前閉后開(kāi) ROW COLUMN+CELL 1001 column=info:age, timestamp=1650518056828, value=28 1001 column=info:id, timestamp=1650518051442, value=1 1001 column=info:name, timestamp=1650518051501, value=\xE5\xBC\xA0\xE4\xB8\x89 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:id, timestamp=1650518373023, value=2 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B 2 row(s) in 0.0310 seconds hbase(main):036:0> scan 'year',{STARTROW => '1001'} ROW COLUMN+CELL 1001 column=info:age, timestamp=1650518056828, value=28 1001 column=info:id, timestamp=1650518051442, value=1 1001 column=info:name, timestamp=1650518051501, value=\xE5\xBC\xA0\xE4\xB8\x89 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:id, timestamp=1650518373023, value=2 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B 1003 column=info:age, timestamp=1650518386062, value=16 1003 column=info:id, timestamp=1650518382621, value=3 1003 column=info:name, timestamp=1650518382650, value=wangwu 3 row(s) in 0.0620 seconds12.查看表結(jié)構(gòu)
#語(yǔ)法 descride '表名' #例如 hbase(main):037:0> describe 'year' Table year is ENABLED year COLUMN FAMILIES DESCRIPTION {NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE ', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'} 1 row(s) in 0.0450 seconds13.更新指定字段的數(shù)據(jù)
#語(yǔ)法 put '表名','行鍵','列簇名','值' #例如 hbase(main):038:0> put 'year', '1001', 'info:id', '1' 0 row(s) in 0.0210 secondshbase(main):039:0> put 'year', '1001', 'info:name', 'zhangsan' 0 row(s) in 0.0120 secondshbase(main):040:0> put 'year', '1001', 'info:age', '22' 0 row(s) in 0.0080 secondshbase(main):041:0> scan 'year' ROW COLUMN+CELL 1001 column=info:age, timestamp=1650519485027, value=22 1001 column=info:id, timestamp=1650519483672, value=1 1001 column=info:name, timestamp=1650519483706, value=zhangsan 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:id, timestamp=1650518373023, value=2 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B 1003 column=info:age, timestamp=1650518386062, value=16 1003 column=info:id, timestamp=1650518382621, value=3 1003 column=info:name, timestamp=1650518382650, value=wangwu 3 row(s) in 0.0290 seconds14.查看指定行的數(shù)據(jù)
#語(yǔ)法 get '表名','行鍵' #例如 hbase(main):042:0> get 'year','1001' COLUMN CELL info:age timestamp=1650519485027, value=22 info:id timestamp=1650519483672, value=1 info:name timestamp=1650519483706, value=zhangsan 1 row(s) in 0.0310 seconds15.查看指定列族的列的數(shù)據(jù)
#語(yǔ)法 get '表名','行鍵','列簇名' #例如 hbase(main):043:0> get 'year','1001','info:age' COLUMN CELL info:age timestamp=1650519485027, value=22 1 row(s) in 0.0110 seconds16.查看行數(shù)
#語(yǔ)法 count '表名' #例如 hbase(main):044:0> count 'year' 3 row(s) in 0.0120 seconds=> 317.刪除某 rowkey 行鍵的全部數(shù)據(jù):
#語(yǔ)法 deleteall '表名','行鍵' #例如 hbase(main):045:0> deleteall 'year','1001' 0 row(s) in 0.0520 secondshbase(main):046:0> scan 'year' ROW COLUMN+CELL 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:id, timestamp=1650518373023, value=2 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B 1003 column=info:age, timestamp=1650518386062, value=16 1003 column=info:id, timestamp=1650518382621, value=3 1003 column=info:name, timestamp=1650518382650, value=wangwu 2 row(s) in 0.0120 seconds18.刪除某 rowkey 的某一列數(shù)據(jù):
#語(yǔ)法 deleteall '表名','行鍵','列簇名' #例如 hbase(main):049:0> deleteall 'year','1002','info:id' 0 row(s) in 0.0050 secondshbase(main):050:0> scan 'year' ROW COLUMN+CELL 1002 column=info:age, timestamp=1650518373828, value=20 1002 column=info:name, timestamp=1650518373053, value=\xE6\x9D\x8E\xE5\x9B\x9B 1003 column=info:age, timestamp=1650518386062, value=16 1003 column=info:id, timestamp=1650518382621, value=3 1003 column=info:name, timestamp=1650518382650, value=wangwu 2 row(s) in 0.0160 seconds19.列舉所有表list?
hbase(main):051:0> list TABLE year 1 row(s) in 0.0110 seconds=> ["year"]20.表是否存在exists
# 語(yǔ)法 exists '表名' #例如 hbase(main):052:0> exists 'year' Table year does exist 0 row(s) in 0.0110 seconds?21.啟用表enable和禁用表disable
通過(guò)enable和disable來(lái)啟用/禁用這個(gè)表,相應(yīng)的可以通過(guò)is_enabled和is_disabled來(lái)檢查表是否被禁用。
# 語(yǔ)法 enable '表名' is_enabled '表名'disable '表名' is_disabled '表名' #例如 hbase(main):053:0> enable 'year' 0 row(s) in 0.0190 secondshbase(main):054:0> is_enabled 'year' true 0 row(s) in 0.0100 secondshbase(main):055:0> hbase(main):056:0* disable 'year' 0 row(s) in 2.2670 secondshbase(main):057:0> is_disabled 'year' true 0 row(s) in 0.0320 seconds22.清空表數(shù)據(jù)
#語(yǔ)法 先禁用表 才能清空數(shù)據(jù) #例如disable 'year'turncate 'year'23.刪除表
#語(yǔ)法 先禁用表 才能刪除表 #例如disable 'year'drop 'year'總結(jié)
以上是生活随笔為你收集整理的HBase shell命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何用c语言编码判断质数,如何用C语言筛
- 下一篇: RDKit新手入门