hbase shell基本操作簡介
阿新 • • 發佈:2018-12-24
之前介紹了hbase的安裝, 現在來簡介下hbase的基本操作:
1. 啟動hbase
start-hbase.sh
啟動後, 可以在頁面http://ip:16010上看到hbase的相關資訊, 其中ip就是安裝hbase的機器的ip
2. 停止hbase
stop-hbase.sh
3. 進入hbase shell
hbase shell
下面直接看操作(hbase表名是student, 列族是grad和subject, rowkey是lucy和lily):
hbase(main):063:0* create 'student', 'grad', 'subject' 0 row(s) in 1.2170 seconds => Hbase::Table - student hbase(main):064:0> hbase(main):065:0* hbase(main):066:0* hbase(main):067:0* list TABLE student 1 row(s) in 0.0120 seconds => ["student"] hbase(main):068:0> hbase(main):069:0* hbase(main):070:0* hbase(main):071:0* put 'student', 'lucy', 'grad:', '1' 0 row(s) in 0.0660 seconds hbase(main):072:0> put 'student', 'lucy', 'subject:math', '60' 0 row(s) in 0.0120 seconds hbase(main):073:0> put 'student', 'lucy', 'subject:physics', '70' 0 row(s) in 0.0120 seconds hbase(main):074:0> put 'student', 'lily', 'grad:', '2' 0 row(s) in 0.0050 seconds hbase(main):075:0> put 'student', 'lily', 'subject:math', '80' 0 row(s) in 0.0070 seconds hbase(main):076:0> put 'student', 'lily', 'subject:chemistry', '90' 0 row(s) in 0.0050 seconds hbase(main):077:0> put 'student', 'lily', 'subject:computer', '100' 0 row(s) in 0.0120 seconds hbase(main):078:0> hbase(main):079:0* hbase(main):080:0* hbase(main):081:0* count 'student' 2 row(s) in 0.0080 seconds => 2 hbase(main):082:0> hbase(main):083:0* hbase(main):084:0* hbase(main):085:0* get 'student' , 'lily' COLUMN CELL grad: timestamp=1519898323259, value=2 subject:chemistry timestamp=1519898333576, value=90 subject:computer timestamp=1519898339578, value=100 subject:math timestamp=1519898327974, value=80 4 row(s) in 0.0120 seconds hbase(main):086:0> hbase(main):087:0* hbase(main):088:0* hbase(main):089:0* get 'student' , 'lily', 'subject' COLUMN CELL subject:chemistry timestamp=1519898333576, value=90 subject:computer timestamp=1519898339578, value=100 subject:math timestamp=1519898327974, value=80 3 row(s) in 0.0090 seconds hbase(main):090:0> hbase(main):091:0* hbase(main):092:0* hbase(main):093:0* get 'student' , 'lily', 'subject:math' COLUMN CELL subject:math timestamp=1519898327974, value=80 1 row(s) in 0.0060 seconds hbase(main):094:0> hbase(main):095:0* hbase(main):096:0* hbase(main):097:0* scan 'student' ROW COLUMN+CELL lily column=grad:, timestamp=1519898323259, value=2 lily column=subject:chemistry, timestamp=1519898333576, value=90 lily column=subject:computer, timestamp=1519898339578, value=100 lily column=subject:math, timestamp=1519898327974, value=80 lucy column=grad:, timestamp=1519898305386, value=1 lucy column=subject:math, timestamp=1519898313749, value=60 lucy column=subject:physics, timestamp=1519898318663, value=70 2 row(s) in 0.0230 seconds hbase(main):098:0> hbase(main):099:0* hbase(main):100:0* hbase(main):101:0* scan 'student', {COLUMN=>'subject'} ROW COLUMN+CELL lily column=subject:chemistry, timestamp=1519898333576, value=90 lily column=subject:computer, timestamp=1519898339578, value=100 lily column=subject:math, timestamp=1519898327974, value=80 lucy column=subject:math, timestamp=1519898313749, value=60 lucy column=subject:physics, timestamp=1519898318663, value=70 2 row(s) in 0.0230 seconds hbase(main):102:0> hbase(main):103:0* hbase(main):104:0* hbase(main):105:0* scan 'student', {COLUMN=>'subject:math'} ROW COLUMN+CELL lily column=subject:math, timestamp=1519898327974, value=80 lucy column=subject:math, timestamp=1519898313749, value=60 2 row(s) in 0.0140 seconds hbase(main):106:0> hbase(main):107:0* hbase(main):108:0* hbase(main):109:0*
一目瞭然, 其餘的更多操作, 不說了, 網上到處都是, 一大堆資料。