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

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

被折叠的 条评论
为什么被折叠?



