- 下载hive安装包:https://dlcdn.apache.org/hive/hive-2.3.9/
- 解压及环境部署
tar -zxvf apache-hive-2.3.9-bin.tar.gz
mv apache-hive-2.3.9-bin hive
vim /etc/profile
添加至环境变量
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
source /etc/profile
编写配置文件
vim hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property>
</configuration>
- 安装mysql
sudo apt-get update #更新软件源
sudo apt-get install mysql-server #安装mysq
验证
service mysql start
sudo netstat -tap | grep mysql
mysql -u root -p #进入mysql shell
配置:
mysql> create user 'hive'@'localhost' identified by 'hive'; #创建用户hive,密码hive
mysql> create database hive; #这个hive数据库与hive-site.xml中localhost:3306/hive的hive对应,用来保存hive元数据
mysql> grant all on *.* to 'hive'@'localhost';#将所有数据库的所有表的所有权限赋给hive用户,后面的hive是配置hive-site.xml中配置的连接密码
mysql> flush privileges#刷新权限
下载mysql jdbc 包
https://dev.mysql.com/downloads/connector/j/
tar -zxvf mysql-connector-j-8.1.0.tar.gz
mv mysql-connector-j-8.1.0 ../mysql
cp mysql/mysql-connector-j-8.1.0.jar /usr/local/hive/lib
注意
4. 启动hive
start-all.sh #启动hadoop
schematool -initSchema -dbType mysql #执行初始化操作
hive #启动hive
验证
show tables;