当前位置:   article > 正文

Hadoop之Hbase建表(详细步骤)_hbase创建表

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的学生的所有信息

  1. put 'StudentAndCourse','2015001','student:S_Name','Zhangsan'
  2. put 'StudentAndCourse','2015001','student:S_Sex','male'
  3. put 'StudentAndCourse','2015001','student:S_Age','23'
  4. put 'StudentAndCourse','2015001','course1:C_No','123001'
  5. put 'StudentAndCourse','2015001','course1:C_Name','Math'
  6. put 'StudentAndCourse','2015001','course1:C_Credit','2.0'
  7. put 'StudentAndCourse','2015001','course1:Score','86'
  8. put 'StudentAndCourse' ,'2015001','course3:C_No','123003'
  9. put 'StudentAndCourse' ,'2015001','course3:C_Name','English'
  10. put 'StudentAndCourse' ,'2015001','course3:C_Credit','3.0'
  11. put 'StudentAndCourse' ,'2015001','course3:Score','69'

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

  1. put 'StudentAndCourse' ,'2015002','student:S_Name','Mary'
  2. put 'StudentAndCourse' ,'2015002','student:S_Sex','female'
  3. put 'StudentAndCourse' ,'2015002','student:S_Age','22'
  4. put 'StudentAndCourse' ,'2015002','course2:C_No','123002'
  5. put 'StudentAndCourse' ,'2015002','course2:C_Name','Conputer Science'
  6. put 'StudentAndCourse' ,'2015002','course2:Credit','5.0'
  7. put "StudentAndCourse" ,'2015002','course2:Score','77'
  8. put 'StudentAndCourse' ,'2015002','course3:C_No','123003'
  9. put 'StudentAndCourse' ,'2015002','course3:C_Name','English'
  10. put 'StudentAndCourse' ,'2015002','course3:Credit','3.0'
  11. put 'StudentAndCourse' ,'2015002','course3:Score','99'

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

  1. put 'StudentAndCourse' ,'2015003','student:S_Name','Lisi'
  2. put 'StudentAndCourse' ,'2015003','student:S_Sex','male'
  3. put 'StudentAndCourse' ,'2015003','student:S_Age','24'
  4. put 'StudentAndCourse' ,'2015003','course1:C_No','123001'
  5. put 'StudentAndCourse' ,'2015003','course1:C_Name','Math'
  6. put 'StudentAndCourse' ,'2015003','course1:C_Credit','2.0'
  7. put 'StudentAndCourse' ,'2015003','course1:Score','98'
  8. put 'StudentAndCourse' ,'2015003','course2:C_No','123002'
  9. put 'StudentAndCourse' ,'2015003','course2:C_Name','Computer Science'
  10. put 'StudentAndCourse' ,'2015003','course2:C_Credit','5.0'
  11. 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/443892?site
推荐阅读
相关标签
  

闽ICP备14008679号