hadoop之Hbase基本shell操作

基本要求:

根据上面给出的student表的信息,执行下面操作

(1)用HBase Shell命令创建学生表Student,并将数据插入表中。

(2)用Scan命令浏览Student表的相关信息。

(3)查询zhangsan的Computer成绩。

(4)修改lisi的Math成绩,改为95。

(5)向Student表中添加数据:name为wangwu,English为80,Math为90,Computer为100,History为70。

(6)统计表的行数。

操作代码如下:

#创建student表
hbase(main):019:0> create 'student','score'
0 row(s) in 2.5870 seconds
=> Hbase::Table - student
#向student表中添加数据
hbase(main):020:0> put 'student','zhangsan','score:English','60'
0 row(s) in 1.0980 seconds

hbase(main):021:0> put 'student','zhangsan','score:Math','86'
0 row(s) in 0.0440 seconds

hbase(main):022:0> put 'student','zhangsan','score:Computer','77'
0 row(s) in 0.0240 seconds
hbase(main):023:0> put 'student','lisi','score:English','55'
0 row(s) in 0.0190 seconds

hbase(main):024:0> put 'student','lisi','score:Math','100'
0 row(s) in 0.0120 seconds

hbase(main):025:0> put 'student','lisi','score:Computer','88'
0 row(s) in 0.0080 seconds

#查看studnet表
hbase(main):026:0> scan 'student'
ROW                    COLUMN+CELL                                                    
 lisi                  column=score:Computer, timestamp=1543593835333, value=88       
 lisi                  column=score:English, timestamp=1543593800832, value=55        
 lisi                  column=score:Math, timestamp=1543593818603, value=100          
 zhangsan              column=score:Computer, timestamp=1543593729816, value=77       
 zhangsan              column=score:English, timestamp=1543593671499, value=60        
 zhangsan              column=score:Math, timestamp=1543593704901, value=86           
2 row(s) in 0.3440 seconds

#修改lisi的Math成绩为95
hbase(main):028:0> put 'student','lisi','score:Math','95'
0 row(s) in 0.0240 seconds

hbase(main):029:0> scan 'student'
ROW                    COLUMN+CELL                                                    
 lisi                  column=score:, timestamp=1543593923169, value=88               
 lisi                  column=score:Computer, timestamp=1543593835333, value=88       
 lisi                  column=score:English, timestamp=1543593800832, value=55        
 lisi                  column=score:Math, timestamp=1543593949960, value=95           
 zhangsan              column=score:Computer, timestamp=1543593729816, value=77       
 zhangsan              column=score:English, timestamp=1543593671499, value=60        
 zhangsan              column=score:Math, timestamp=1543593704901, value=86           
2 row(s) in 0.0650 seconds

#向student表中添加数据:name:wang , English: 80 , Math: 90 , Computer: 100, History:70.


hbase(main):041:0> put 'student','wangwu','score:English','80'
0 row(s) in 0.0120 seconds

hbase(main):042:0> put 'student','wangwu','score:Math','90'
0 row(s) in 0.0060 seconds

hbase(main):043:0> put 'student','wangwu','score:Computer','100'
0 row(s) in 0.0390 seconds

hbase(main):044:0> put 'student','wangwu','score:History','70'
0 row(s) in 0.0220 seconds

hbase(main):045:0> scan 'student'
ROW                    COLUMN+CELL                                                   
 lisi                  column=score:, timestamp=1543593923169, value=88              
 lisi                  column=score:Computer, timestamp=1543593835333, value=88      
 lisi                  column=score:English, timestamp=1543593800832, value=55       
 lisi                  column=score:Math, timestamp=1543593949960, value=95          
 wangwu                column=score:Computer, timestamp=1543594580061, value=100     
 wangwu                column=score:English, timestamp=1543594542458, value=80       
 wangwu                column=score:History, timestamp=1543594599127, value=70       
 wangwu                column=score:Math, timestamp=1543594560116, value=90          
 zhangsan              column=score:Computer, timestamp=1543593729816, value=77      
 zhangsan              column=score:English, timestamp=1543593671499, value=60       
 zhangsan              column=score:Math, timestamp=1543593704901, value=86          
3 row(s) in 0.1540 seconds

#统计表的行数
hbase(main):048:0* count 'student'
3 row(s) in 0.5310 seconds
View Code

可参考:

1)http://www.cnblogs.com/nexiyi/p/hbase_shell.html

2)https://www.cnblogs.com/cxzdy/p/5583239.html

 

posted @ 2018-11-30 16:26  命由己造~  阅读(926)  评论(0)    收藏  举报