1. 安装前准备
1.1 安装hadoop
Hadoop 3.3.2 离线安装_shangjg3的博客-CSDN博客
1.2 在mysql中创建hivemeta数据库,用于保存hive的元数据
mysql -u root -p
mysql> create database hivemeta;
2. 安装
2.1 下载编译好的tar包
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz --no-check-certificate
tar -zxvf apache-hive-3.1.3-bin.tar.gz
2.2. 下载mysql驱动
wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.47/mysql-connector-java-5.1.47.jar
将驱动放到/data/olap/hive-3.1.3/lib 目录
2.3 新增hive配置hdfs-site.xml
vim /data/olap/hive-3.1.3/conf/hdfs-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- Hive 元数据的存放位置 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://10.16.60.62:3306/hivemeta?useSSL=false</value>
</property>
<!-- 指定驱动程序 -->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<!-- 连接数据库的用户名 -->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<!-- 连接数据库的密码 -->
<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.metastore.uris</name>
<value>thrift://master:9083</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>master</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>
2.4 初始化hive
cd /data/olap/hive-3.1.3/bin
./schematool -initSchema -dbType mysql --verbose
#返回信息
0: jdbc:mysql://10.16.60.62:3306/hivemeta> !closeall
Closing: 0: jdbc:mysql://10.16.60.62:3306/hivemeta?useSSL=false
beeline>
beeline> Initialization script completed
schemaTool completed
3. hive基础操作
3.1 启动hive
nohup ./hive --service metastore > ../logs/metastore.log 2>&1 &
nohup ./hive --service hiveserver2> ../logs/hive2.log 2>&1 &