数据仓库组件:Hive环境搭建和基础用法( 二 )

javax.jdo.option.ConnectionUserNamerootusername to use against metastore databasejavax.jdo.option.ConnectionPassword123456password to use against metastore database配置完成后 , 依次重启MySQL、hadoop、hive环境 , 查看MySQL数据库信息 , 多了metastore数据库和相关表 。
4、后台启动hiveserver2
[root@hop01 hive1.2]# bin/hiveserver2 &5、Jdbc连接测试
[root@hop01 hive1.2]# bin/beelineBeeline version 1.2.1 by Apache Hivebeeline> !connect jdbc:hive2://hop01:10000Connecting to jdbc:hive2://hop01:10000Enter username for jdbc:hive2://hop01:10000: hiveroot (账户回车)Enter password for jdbc:hive2://hop01:10000: ******(密码123456回车)Connected to: Apache Hive (version 1.2.1)Driver: Hive JDBC (version 1.2.1)0: jdbc:hive2://hop01:10000> show databases;+----------------+--+| database_name|+----------------+--+| default|+----------------+--+四、高级查询语法1、基础函数
select count(*) count_user from hv_user;select sum(age) sum_age from hv_user;select min(age) min_age,max(age) max_age from hv_user;+----------+----------+--+| min_age| max_age|+----------+----------+--+| 23| 25|+----------+----------+--+2、条件查询语句
select * from hv_user where name='test-user' limit 1;+-------------+---------------+--------------+--+| hv_user.id| hv_user.name| hv_user.age|+-------------+---------------+--------------+--+| 1| test-user| 23|+-------------+---------------+--------------+--+select * from hv_user where id>1 AND name like 'dev%';+-------------+---------------+--------------+--+| hv_user.id| hv_user.name| hv_user.age|+-------------+---------------+--------------+--+| 2| dev-user| 25|+-------------+---------------+--------------+--+select count(*) count_name,name from hv_user group by name;+-------------+------------+--+| count_name|name|+-------------+------------+--+| 1| dev-user|| 1| test-user|+-------------+------------+--+3、连接查询
select t1.*,t2.* from hv_user t1 join hv_dept t2 on t1.id=t2.dp_id;+--------+------------+---------+-----------+-------------+--+| t1.id|t1.name| t1.age| t2.dp_id| t2.dp_name|+--------+------------+---------+-----------+-------------+--+| 1| test-user| 23| 1| 技术部|+--------+------------+---------+-----------+-------------+--+
【数据仓库组件:Hive环境搭建和基础用法】


推荐阅读