Hadoop之Hbase建表(详细步骤)

本文档详细介绍了如何启动Hadoop的HDFS和HBase,接着通过HBase shell创建名为'StudentAndCourse'的表,并插入三个学生(2015001, 2015002, 2015003)的详细信息,包括姓名、性别、年龄、课程及成绩。之后展示了如何使用scan命令查看表中的数据,并提示可以在Web界面中查看。最后,演示了如何退出HBase shell以及停止HDFS和HBase服务。

1、启动HDFS和HBase

cd /home/ZQ/hadoop-2.7.6/sbin
start-dfs.sh
cd /home/ZQ/hbase-1.4.13/bin/
start-hbase.sh

2、进入hbase shell

cd
hbase shell

 3、创建表

create 'StudentAndCourse','student','course1','course2','course3'

4、插入数据

①新增学号为2015001的学生的所有信息

put 'StudentAndCourse','2015001','student:S_Name','Zhangsan'
put 'StudentAndCourse','2015001','student:S_Sex','male'
put 'StudentAndCourse','2015001','student:S_Age','23'
put 'StudentAndCourse','2015001','course1:C_No','123001'
put 'StudentAndCourse','2015001','course1:C_Name','Math'
put 'StudentAndCourse','2015001','course1:C_Credit','2.0'
put 'StudentAndCourse','2015001','course1:Score','86'
put 'StudentAndCourse' ,'2015001','course3:C_No','123003'
put 'StudentAndCourse' ,'2015001','course3:C_Name','English'
put 'StudentAndCourse' ,'2015001','course3:C_Credit','3.0'
put 'StudentAndCourse' ,'2015001','course3:Score','69'

②、新增学号为2015002的学生的所有信息

put 'StudentAndCourse' ,'2015002','student:S_Name','Mary'
put 'StudentAndCourse' ,'2015002','student:S_Sex','female'
put 'StudentAndCourse' ,'2015002','student:S_Age','22'
put 'StudentAndCourse' ,'2015002','course2:C_No','123002'
put 'StudentAndCourse' ,'2015002','course2:C_Name','Conputer Science'
put 'StudentAndCourse' ,'2015002','course2:Credit','5.0'
put "StudentAndCourse" ,'2015002','course2:Score','77'
put 'StudentAndCourse' ,'2015002','course3:C_No','123003'
put 'StudentAndCourse' ,'2015002','course3:C_Name','English'
put 'StudentAndCourse' ,'2015002','course3:Credit','3.0'
put 'StudentAndCourse' ,'2015002','course3:Score','99'

③、新增学号为2015003的学生的所有信息

put 'StudentAndCourse' ,'2015003','student:S_Name','Lisi'
put 'StudentAndCourse' ,'2015003','student:S_Sex','male'
put 'StudentAndCourse' ,'2015003','student:S_Age','24'
put 'StudentAndCourse' ,'2015003','course1:C_No','123001'
put 'StudentAndCourse' ,'2015003','course1:C_Name','Math'
put 'StudentAndCourse' ,'2015003','course1:C_Credit','2.0'
put 'StudentAndCourse' ,'2015003','course1:Score','98'
put 'StudentAndCourse' ,'2015003','course2:C_No','123002'
put 'StudentAndCourse' ,'2015003','course2:C_Name','Computer Science'
put 'StudentAndCourse' ,'2015003','course2:C_Credit','5.0'
put 'StudentAndCourse' ,'2015003','course2:Score','95'

5、查看表的数据

scan 'StudentAndCourse'

6、查看web界面

在浏览器中输入10.103.105.62:60010(主节点)进行查看

 

退出hbase shell 

exit

7、停止hbase和HDFS

cd /home/ZQ/hbase-1.4.13/bin/
stop-hbase.sh
cd /home/ZQ/hadoop-2.7.6/sbin
stop-dfs.sh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值