在此进行Hive-3.1.2并以Mysql作为元数据库的基本安装配置,假设你已安装好Mysql数据库(Mysql安装配置可见:Centos 7 安装配置mysql 5.7 超详细笔记)。
1 软件下载
#Hive 3.1.2
https://dlcdn.apache.org/hive/hive-3.1.2/
#Mysql Connector, 注意下载Platform Independent版本,并解压得到Jar包
https://dev.mysql.com/downloads/connector/j/
2 解压Hive到对应目录
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /usr/sft/hive-3.1.2/
3 添加环境变量到 /etc/profile
export HIVE_HOME=/usr/sft/hive-3.1.2 export PATH=$PATH:$HIVE_HOME/bin
#4 将上述Mysql Connector Jar拷贝到 $HIVE_HOME/lib/
cp mysql-connector-java-8.0.26.jar /usr/sft/hive-3.1.2/lib/
#5 添加$HIVE_HOME/conf/hive-site.xml内容如下
javax.jdo.option.ConnectionURL jdbc:mysql://chdp01:3306/hivemetastore?createDatabaseIfNotExist=true&useSSL=false javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver javax.jdo.option.ConnectionUserName root hive.metastore.warehouse.dir /user/hive/warehouse javax.jdo.option.ConnectionPassword MyPwd123@ hive.server2.active.passive.ha.enable true
#6 修改hive-env.sh对应内容如下,根据实际情况配置
export HADOOP_HEAPSIZE=512
#7 修改hive_log4j.properties配置日志路径
property.hive.log.dir=/usr/sft/hive-3.1.2/logs
#8 初始化Hive,此时会在Mysql中创建对应hivemetastore DB和相关配置表,注意启动Mysql服务
schematool -initSchema -dbType mysql -verbose
#9 启动hive建个表试试,注意在此之前须启动Hdfs
create table if not exists user_t( id bigint, name string, sex string, age int )comment 'this is a test' partitioned by (dt date) row format delimited fields terminated by 't' stored as parquet ;
查看Mysql可以发现我们创建的表元数据描述



