1、下载tar包 解压
2、安装mysql
3、修改hive配置文件
vim hive-env.sh
HADOOP_HOME=/usr/local/hadoop-2.9.2
export HIVE_CONF_DIR=/usr/local/apache-hive-2.3.9-bin/conf
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.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.100.3.21:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>node-1</value>
</property>
<property>
<name>datanucleus.schema.autoCreateAll</name>
<value>true</value>
</property>
</configuration>
4、添加mysql驱动
将mysql 驱动mysql-connector-java-8.0.18.jar
放置到lib目录下
5、配置hive环境变量
export HIVE_HOME=/usr/local/apache-hive-2.3.9-bin
export PATH=$HIVE_HOME/bin:$PATH
6、初始化元数据库
schematool -dbType mysql -initSchema
# 2.x版本Hive需要手动初始化
7、使用
$ hive
hive> show database;
hive> create database mytest;
hive> use mytest;
hive> create table book(id int, name string);