一、嵌入模式安装
1、下载Hive安装包
https://archive.apache.org/dist/hive/hive-1.2.1/
2、上传至/root/export/software/
rz apache-hive-1.2.1-bin.tar.gz
3、解压
tar apache-hive-1.2.1-bin.tar.gz -C /root/export/servers/
cd /root/export/servers/apache-hive-1.2.1-bin
4、启动
bin/hive
效果如下:
5、查看数据库
show databases;
二:本地模式安装
1、在线安装mysql
yum install mysql mysql-server mysql-devel
#出现下面情况追加命令:
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
#启动mysql
service mysqld start/stop/status
输入mysql;
设置密码:
use mysql;
Update user SET Password=PASSWORD('123456') Where User='root';
#设置允许远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
#刷新写入
FLUSH PRIVILEGES;
2、Hive配置
(1)、修改hive-env.sh 配置文件,配置hadoop环境变量
cd /root/export/servers/apache-hive-1.2.1-bin/conf/
cp hive-env.sh.template hive-env.sh
(2) 、修改hadoop目录
vim hive-env.sh
HADOOP_HOME=/root/export/servers/hadoop-2.7.4
(3)、创建hive-site.xml配置
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<description>Mysql连接协议</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Mysql连接协议</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>用户名</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>密码</description>
</property>
</configuration>
(4)、上传mysql-connector-java-5.1.32.jar到hive的bin目录
cd /root/export/servers/apache-hive-1.2.1-bin/bin
rz mysql-connector-java-5.1.32.jar
到此安装完毕
备注:如果使用远程模式安装方式,只需要将hive-site.xml配置中的localhost修改为具有MySQL服务节点IP即可,这样无论用户通过什么路径下启动Hive客户端,都可以访问相同的元数据信息。