HIVE 3.1.2 安装

HIVE 3.1.2 安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 0、准备工作(安装之前请确保 hadoop3.1.3 和 mysql8 已安装且服务已启动)
linux hive 安装压缩包 apache-hive-3.1.2-bin.tar.gz 上传至 /opt/download/second下
mysql8 链接驱动包 mysql-connector-j-8.0.33.jar 上传至 /opt/download/second下

# 1、解压并重命名
cd /opt/download
tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/software/
mv /opt/softwareapache-hive-3.1.2-bin/ /opt/software/hive-3.1.2
cd /opt/software/hive-3.1.2

# 2、环境变量并激活
vim /etc/profile.d/my.sh
#-----------------------------------------
# hive
export HIVE_HOME=/opt/software/hive312
export PATH=$PATH:$HIVE_HOME/bin
#-----------------------------------------
source /etc/profile

# 3、配置文件
mv conf/hive-default.xml.template conf/hive-default.xml
1
2
# 新建编辑hive-site.xml# 
vim conf/hive-site.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration>
<!--关闭客户端和hive2服务远程通信安全验证-->
<property>
<name>hive.metastore.sasl.enabled</name>
<value>false</value>
</property>
<!--关闭客户端和hive2代理用户身份验证,使用默认用户-->
<property>
<name>hive.server2.enable.doAs</name>
<value>false</value>
</property>
<!--配置hive2认证机制:NONE,NOSASL,LDAP,KERBEROS-->
<property>
<name>hive.server2.authentication</name>
<value>NONE</value>
</property>
<!--metastore(元)数据HDFS目录-->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/hive312/warehouse</value>
</property>
<!--metastore(元)数据库类型-->
<property>
<name>hive.metastore.db.type</name>
<value>mysql</value>
</property>
<!--连接mysql字符串-->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://zyh:3306/hive312?createDatabaseIfNotExist=true</value>
</property>
<!--mysql连接驱动-->
<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>
<!--关闭hive启动是是否对metadata的schema验证-->
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<!--提示当前库名-->
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<!--查询输出显示列名-->
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
</configuration>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#4、拷贝mysql驱动
cp /opt/download/mysql-connector-j-8.0.33.jar lib/

#5、更新guava包和hadoop一致
ls lib/|grep guava
# guava-19.0.jar
rm -f lib/guava-19.0.jar
find /opt/software/hadoop-3.1.3/ -name guava*
#/opt/software/hadoop313/share/hadoop/common/lib/guava-27.0-jre.jar
#/opt/software/hadoop313/share/hadoop/hdfs/lib/guava-27.0-jre.jar
cp /opt/software/hadoop-3.1.3/share/hadoop/hdfs/lib/guava-27.0-jre.jar lib/

#7、初始化(确保 mysql8 已经开启远程链接用户并授权)
schematool -dbType mysql -initSchema

#8、hive启动模式
#首先启动元数据服务
nohup hive --service metastore 1>/dev/null 2>&1 &

#1、方法一 hive客户端
hive
#2、方法二 基于metastore和hiveserver2的beeline
#启动hiveserver2服务
nohup hive --service hiveserver2 1>/dev/null 2>&1 &
beeline -u jdbc:hive2://localhost:10000

##################
# HIVE UDF 3.1.2 #
##################
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>${hive.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>${hive.version}</version>
</dependency>

HIVE 3.1.2 安装
https://leaf-domain.gitee.io/2025/03/22/bigdata/hive/hive_install/
作者
叶域
发布于
2025年3月22日
许可协议