Centos7安装Hive mysql

第十单元 完全分布式、Hive

2、Hive

Hive是数据仓库:

zhangsan math 99
lisi math 88
wangwu math 78
zhangsan english 69
lisi english 87
wangwu english 79

1、数据文件

2、对数据文件的表、字段等描述信息(元数据信息,默认使用derby存放元数据信息,建议使用Mysql存放元数据信息)

select avg(成绩) from 表名 group by name;

步骤:

1、解压hive

2、重命名配置文件,并修改文件/opt/apache-hive-1.2.2-bin/conf

mv hive-default.xml.template hive-site.xml

3、清空 echo >hive-site.xml

4、

<configuration>
<property>
<name>javax.jdo.option.ConnectionURLname>
<value>jdbc:mysql://hdp1:3306/hive?createDatabaseIfNotExist=truevalue>
property>
<property>
<name>javax.jdo.option.ConnectionDriverNamename>
<value>com.mysql.jdbc.Drivervalue>
property>
<property>
<name>javax.jdo.option.ConnectionUserNamename>
<value>rootvalue>
property>
<property>
<name>javax.jdo.option.ConnectionPasswordname>
<value>rootvalue>
property>
configuration>

将mysql驱动包拷贝到hive/lib目录中

cp /opt/mysql-connector-java-5.1.28.jar /opt/apache-hive-1.2.2-bin/lib

5、CentOS7安装Mysql

第一步:安装从网上下载文件的wget命令

[root@localhost ~]# yum -y install wget

第二步:下载mysql的repo源

[root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 

第三步:安装mysql-community-release-el7-5.noarch.rpm包

[root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

第四步:查看确认下

第五步:安装mysql

[root@localhost ~]# yum install mysql-server


启动:
systemctl start mysqld.service

登录mysql:

mysql
或mysql -hlocalhost -uroot -p

修改host为hdp1的用户名和密码:

use mysql;

select host,user,password from user;


UPDATE user SET Password = PASSWORD('123') WHERE user = 'root' and host='zsw1.localdomain';
FLUSH PRIVILEGES;


+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root |                                           |
| hdp1      | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 127.0.0.1 | root |                                           |
| ::1       | root |                                           |
| localhost |      |                                           |
| hdp1      |      |                                           |
+-----------+------+-------------------------------------------+

测试案例:

select avg(score) avgscore from student group by name order by avgscore desc;

你可能感兴趣的:(Centos7安装Hive mysql)