Files
www.colben.cn/content/post/hive2-tez.md
2026-03-26 20:12:07 +08:00

109 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "hive2 tez 部署"
date: 2023-05-23T12:00:00+08:00
lastmod: 2023-05-23T12:00:00+08:00
keywords: []
tags: ["hadoop", "hive", "tez"]
categories: ["hadoop"]
---
## 环境
操作系统 | 主机名 | 地址 | 运行组件
---- | ---- | ---- | ----
Rocky8 | 编译服务器 | - | 编译工具
Rocky9 | hive-hs20 | 192.168.8.20/24 | Hive Server, Tez
Rocky9 | hive-ms21 | 192.168.8.21/24 | Hive Metastore, MySQL8.0, Tez
## 准备 protoc 2.5.0 环境
- 在**编译服务器**上执行如下操作
- 下载源码,解压
```bash
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
tar zxf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0.tar.gz
```
- 编译
```bash
mkdir /opt/protoc-2.5.0
./configure --prefix=/opt/protoc-2.5.0
make
make check
make install
```
## 编译 tez
- 在**编译服务器**上执行如下操作
- 下载 tez 部署包,解压
```bash
curl -LO https://mirrors.tuna.tsinghua.edu.cn/apache/tez/0.9.2/apache-tez-0.9.2-src.tar.gz
tar zxf apache-tez-0.9.2-src.tar.gz
cd apache-tez-0.9.2-src
```
- 编译
```bash
export PATH=/opt/protoc-2.5.0/bin:/opt/jdk8/bin:/opt/maven3/bin:$PATH
mvn clean package -DskipTests=true -Dtar -Dhadoop.version=2.10.2 -Dmaven.javadoc.skip=true -pl tez-dist -am
```
- 上传 tez-dist/target/tez-0.9.2-minimal.tar.gz 到**全部 hive 服务器**中
- 上传 tez-dist/target/tez-0.9.2.tar.gz 到 **hive-hs20** 中
## 部署 tez 环境
- 在 **hive-hs20** 上 put tez-0.9.2.tar.gz 到 hdfs
```bash
hdfs dfs -mkdir /tez
hdfs dfs -put tez-0.9.2.tar.gz /tez/
```
- 在**全部 hive 主机**上解压 tez 部署包
```bash
mkdir /opt/tez
tar zxf tez-0.9.2-minimal.tar.gz -C /opt/tez/
```
### 修改 yarn-site.xml
- 在**全部主机(包括 hadoop)**上[关闭 yarn 虚拟内存检查](/post/hdp2/#修改-yarn-sitexml)
### 创建 tez-site.xml
- 在**全部主机(包括 hadoop)**上执行如下操作
- 创建 $HADOOP_HOME/etc/hadoop/tez-site.xml参考内容如下
```xml
<configuration>
<property>
<name>tez.lib.uris</name>
<type>string</type>
<value>${fs.defaultFS}/tez/tez-0.9.2.tar.gz</value>
</property>
</configuration>
```
### 修改 hive-env.sh
- 在**全部 hive 主机**上执行如下操作
- 编辑 $HIVE_HOME/conf/hive-env.sh在文件最后增加如下内容
```bash
export TEZ_HOME=/opt/tez
TEZ_JARS=""
for jar in $(ls $TEZ_HOME | grep jar); do
TEZ_JARS=$TEZ_JARS:$TEZ_HOME/$jar
done
for jar in $(ls $TEZ_HOME/lib); do
TEZ_JARS=$TEZ_JARS:$TEZ_HOME/lib/$jar
done
export HIVE_AUX_JARS_PATH=$TEZ_HOME/lib
export HADOOP_CLASSPATH=$TEZ_JARS
```
## 重启环境
- 重启 hadoop dfs 和 yarn 集群
- 重启 hive metastore 和 hiveserver2
## 设置引擎
- 客户端连接 hive设置引擎为 tez执行 sql 语句
```sql
set hive.execution.engine=tez;
-- 后面操作数据时不再报 "WARNING: Hive-on-MR is deprecated in Hive 2 ..."
```