Hbase和Hive基础操作

(1)启动Hbase并用jps查看Hbase进程信息查看Hbase服务器的Web管理端(端口号是16010)

[root@lixianhui38 ~]# start-hbase.sh
[root@lixianhui38 ~]# jps

 

 (2)启动Hbase Shell并查看Hbase版本信息

[root@lixianhui38 ~]# hbase shell
hbase(main):001:0> version

 (3)在Hbase数据库中创建studentt38的表列族是baseinfo,homeinfo,scores

hbase(main):002:0> create 'studentt38','baseinfo','homeinfo','scores'

 (4)查看创建的student表的描述信息

hbase(main):004:0> desc 'studentt38'

 (5)查看Hbases数据库所有表的列表

hbase(main):005:0> list

 (6)向创建的studentt38表中输入下面数据:rowKey 你的学号 ,baesinfo name 你的姓名,baseinfo age 你的年龄, homeinfo native 你的籍贯,scores bigdata 你期望的成绩

hbase(main):006:0> put 'studentt38','202018038','baseinfo:name','lixianhui'                                                                                
hbase(main):007:0> put 'studentt38','202018038','baseinfo:age','20'
hbase(main):011:0> put 'studentt38','202018038','homeinfo:native','jinan'                                                                                  
hbase(main):012:0> put 'studentt38','202018038','scores:bigdata','98'

 

 (7)向创建的studentt38表中输入下面数据:rowKey 2020001 ,baesinfo name 自定义,baseinfo school 学校, homeinfo postcode 250010,scores bigdata 60

hbase(main):001:0> put 'studentt38','2020001','baseinfo:name','zhangsan'                                                                                  
hbase(main):002:0> put 'studentt38','2020001','baseinfo:school','lisi'                                                                             
hbase(main):003:0> put 'studentt38','2020001','homeinfo:postcode','250010'                                                                               
hbase(main):004:0> put 'studentt38','2020001','scores:bigdata','60'

 (8)查看studentt38表中所有数据,查看studentt38表中rowkey为2020001的所有数据

hbase(main):001:0> scan 'studentt38'
hbase(main):002:0> get 'studentt38','2020001'

 

 (9)在bin目录下启动hive

[root@lixianhui38 ~]# cd /opt/apps
[root@lixianhui38 apps]# ls
[root@lixianhui38 apps]# cd hive
[root@lixianhui38 hive]# ls
[root@lixianhui38 hive]# bin/hive

 

 (10)在hive shell中创建数据表docs38表中包含类型为字符串的line字段

hive> create table docs38(line string);

 

 (11)将/opt/apps/hadoop/lixianhui.txt文本内容加载到docs38表中

hive> load data local inpath '/opt/apps/hadoop/lixianhui.txt' into table docs38;

 (12)使用sql语句查询docs38表中有多少条数据

hive> select count(*) from docs38;

posted on 2022-05-19 16:57  昨夜小楼听风雨  阅读(81)  评论(0编辑  收藏  举报