This commit is contained in:
colben
2026-03-25 21:56:21 +08:00
parent 9386632288
commit 196342d9b8
3 changed files with 36 additions and 36 deletions

View File

@@ -25,8 +25,8 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
echo "192.168.8.3 hdp-dn" >> /etc/hosts
echo "192.168.8.10 hdp-slave10" >> /etc/hosts
echo "192.168.8.11 hdp-slave11" >> /etc/hosts
echo "192.168.8.20 hdp-hs20" >> /etc/hosts
echo "192.168.8.21 hdp-ms21" >> /etc/hosts
echo "192.168.8.20 hive-hs20" >> /etc/hosts
echo "192.168.8.21 hive-ms21" >> /etc/hosts
```
## 创建 mysql 数据库
@@ -34,9 +34,9 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
- 部署 mysql8.0,略过
- 创建用户及其数据库,参考 sql 如下
```sql
create user hive@127.7.7.7 identified by 'Hive_1234';
create user hive@'%' identified by 'Hive_1234';
create database hive default charset utf8mb4;
grant all on hive.* to hive@127.7.7.7;
grant all on hive.* to hive@'%';
```
## 复制 jdk 和 hadoop 环境
@@ -54,8 +54,8 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
- 下载 hive 2.3.9 部署包,解压
```bash
curl -LO https://archive.apache.org/dist/hive/hive-2.3.9/apache-hive-2.3.9-bin.tar.gz
tar zxf apache-hive-2.3.9.tar.gz
mv apache-hive-2.3.9 /opt/hive
tar zxf apache-hive-2.3.9-bin.tar.gz
mv apache-hive-2.3.9-bin /opt/hive
```
- 下载 mysql 连接库,解压到 hive 库目录下
@@ -76,7 +76,7 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
### 修改 hive-env.sh
- 编辑 $HIVE_HOME/conf/hive-env.sh指定 HADOOP_HOME 环境变量
```bash
export HADOOP_HOME=/opt/hdp
HADOOP_HOME=/opt/hdp
```
### 创建 hive-site.xml
@@ -86,7 +86,7 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
<property>
<!-- mysql 地址 -->
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.7.7.7:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
<value>jdbc:mysql://hive-ms21:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
</property>
<property>
<!-- mysql 驱动 -->
@@ -136,14 +136,10 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
<name>hive.execution.engine</name>
<value>tez</value>
</property> -->
<property>
<name>tez.am.staging-dir</name>
<value>/hive/tez/staging</value>
</property>
</configuration>
```
## 初始化 hive 库
### 初始化 hive 库
- 在 **hive-ms21** 上执行如下操作
```bash
schematool -dbType mysql -initSchema
@@ -164,10 +160,12 @@ Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0
- 本地直接连接
```bash
hive
# 暂时忽略"WARNING: Hive-on-MR is deprecated in Hive 2 ..."
```
- beeline 连接,需要[在 $HADOOP_HOME/etc/hadoop/core-site.xml 中配置 proxyuser](/post/hdp2/#修改-core-sitexml)
```bash
beeline -u jdbc:hive2://hive-hs20:10000 -n root
# 暂时忽略"WARNING: Hive-on-MR is deprecated in Hive 2 ..."
```