安装hive之前确保已经安装mysql
1、解压
tar -xvf apache-hive-3.1.2-bin.tar.gz -C /opt/software/
#改名
mv apache-hive-3.1.2-bin/ hive-3.1.2
cd /opt/software/hive-3.1.2/conf/
2.创建hive-size.xml 我安装的是mysql-8.xx.xx,driver路径是com.mysql.cj.jdbc.Driver,如果是mysql-5.xx.xx的去掉cj就可以了
vim hive-size.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop1:3306/metastore?useSSL=false</value>
</property>
<!--Driver路径-->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<!--mysql用户名-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<!--mysql密码-->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>hadoop1</value>
</property>
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
</configuration>
3. 创建数据库
mysql -uroot -p123456
create database metastore;
4下载地址 两个都可以,解压将里面的mysql-connector-java-8.0.18.jar放到/hive-3.1.2/lib目录下
5.格式化
schematool -initSchema -dbType mysql -verbose
6、输入hive