掌握使用HBase shell進行表操作
(一). 實驗環境
(章魚大數據)HBase
(二). 實驗步驟
1. 創建student表,表結構包含info和course列族,顯示表結構。
create 'student','info','course'

2. 修改表結構,course列族返回最大版本數為3,顯示表結構。
alter 'studemt',{'NAME'=>'course','VERSIONS'=>'3'}
desc 'student'

3. 輸入數據,要求至少包括以下列
(具體數據自定,course列族要輸入部分小於60分的數據)
info列族:name、age、sex、dept
course列族:english、math、physics
put 'student','201601','info:name','liu',4
put 'student','201601','info:age',15
put 'student','201601','info:sex','nv'
put 'student','201601','info:dept','PE'
put 'student','201602','info:name','wang'
put 'student','201602','info:age',16,7
put 'student','201602','info:sex','nan'
put 'student','201602','info:dept','PC'
put 'student','201603','info:name','sun',6
put 'student','201603','info:age',19
put 'student','201603','info:sex','nv'
put 'student','201603','info:dept','JAVA'
put 'student','201601','course:english',72,3
put 'student','201601','course:math',79
put 'student','201601','course:'physics',82
put 'student','201602','course:english',62
put 'student','201602','course:math',68,8
put 'student','201602','course:'physics',49
put 'student','201603','course:english',73,8
put 'student','201603','course:math',69
put 'student','201603','course:'physics',48,6


4. 更新數據,將course列族中小於60的數據更新為60。
put 'student','201602','course:physics',60
put 'student','201603','course:physics',60


5. 使用get進行數據查詢。
get 'student','201601',{COLUMN=>'course',TIMERANGE=>3}
get 'student','201603',{COLUMN=>'course',TIMERANGE=>[6,8]}

6. 使用scan進行查詢。
scan 'student',{COLUMN => 'info:dept'}
scan 'student',{COLUMN => 'info:name'}

7. 使用過濾器進行查詢。
scan 'student',{FILTER=>"TimestampFilter(3,8)"}
scan 'student',FILTER=>"RowFilter(=,'substring:2')"


8. 創建student表的快照stu_snap,顯示快照列表。
snapshot 'student','stu_snap'
list_snapshots

9. 通過快照stu_snap生成新表stu_info,並顯示stu_info表結構。
clone_snapshot 'stu_snap','stu_info'


10. 刪除快照stu_snap,刪除student表。
delete_snapshot 'stu_snap'


(三)實驗總結
通過這次實驗,我學會了Hbase的基本操作,即創建表、對表進行增刪改查、利用過濾器查詢以及一些快照操作。在創建表時應該注意字母的大小寫,Hbase是區分大小寫的;在刪除表之前,需要先將表禁用,再進行刪除;在使用過濾器查詢時應注意單詞拼寫及大小寫;snapshot命令可以建立表的快照。
