1.安装和配置mysql
a.yum安装mysql
[root@masterroot]# yum install mysql-server(集群都要装mysql,但只配置一个即可)
b.启动mysql服务
#service /etc/init.d/mysqld start
c.删除匿名用户
在root权限下 mysql -uroot -p进入mysql命令行
mysql>create database hive_db;
mysql>delete from mysql.user where user='';
mysql>flush privileges;
d.创建hive用户‘hive’,并分配权限
mysql>create user 'hive'@'%' identified by 'hive'
mysql>grant all privileges on hive_db.* to 'hive'@'%' with grant option;//远程用户
mysql>create user 'hive'@'localhost' identified by 'hive'
mysql>grant all privileges on hive_db.* to 'hive'@'localhost' with grant option;
mysql>create user 'hive'@'本机hostname' identified by 'hive'
mysql>grant all privileges on hive_db.* to 'hive'@'本机hostname' with grant option;
mysql>flush privileges;
创建了用户hive和数据库hive_db,并且将hive_db的全部权限分配给此用户
e.测试是否安装和配置成功
1)本机测试
[root@masterroot]# mysql -uhive -phive
2)用我的实体机进行联机测试
joney@joney-pc:~$mysql -h本机ip -uhive -phive
2.安装和配置hive
a.hive的安装
在/opt目录下对hive-0.11.0.tar.gz进行解压即完成
[root@masteropt]# tar -zxf hive-0.11.0.tar.gz, 在/opt目录下会
出现目录hive-0.11.0,我把该目录重新命名为hive0110
b.配置mysql-connector-java包(到mysql官网下载)
解压mysql-connector-java-5.1.25.tar.gz,将其中的mysql-connector-java- 5.1.25-bin.jar文件拷贝到hive安装目录下的lib文件夹
[root@masteropt]# tar -zxf mysql-connector-java-5.1.25.tar.gz
[[email protected]]# cp./ysql-connector-java- 5.1.25-bin.jar /opt/hive0110/lib
c.配置hive
1)修改环境变量
[root@masteropt]# vim /etc/profile, 在文件末尾追加如下内容:
#sethive path
exportHIVE_HOME=/opt/jdk1.7.0_25
exportPATH=$PATH:$HIVE_HOME/bin
2)重启系统,进行验证
[root@masteropt]# echo $HIVE_HOME
3)修改hive配置文件/opt/hive0110/conf/hive-site.xml
i.拷贝模板
[root@masterconf]# cp hive-default.xml.template hive-site.xml
ii.修改相关属性
3.启动及验证hive
1)启动hive并创建测试表t_test
[root@masteropt]# hive
hive>create table t_test(a string, b string);
hive>show tables;
2)查看hdfs中表t_test对应的存储目录
hive>dfs -ls /user/hive/warehouse;
3)用我的实体机查看metastor数据库状态
joney@joney-pc:~$mysql -h 10.255.24.191 -u hive -p
mysql>use hvie_db;
mysql>show tables;
mysql>select * from TBLS where tbl_name = 't_test';