Files
www.colben.cn/content/post/tez.md
2026-03-24 22:07:34 +08:00

119 lines
3.2 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: ["storage"]
---
## 环境
操作系统 | 主机名 | 地址 | 运行组件
---- | ---- | ---- | ----
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** 执行如下操作
- 上传 tez-0.9.2.tar.gz 到 hdfs
```bash
hdfs dfs -mkdir /tez
hdfs dfs -put tez-0.9.2.tar.gz /tez/
```
- 创建 tez staging 目录
```bash
hdfs dfs -mkdir -p /hive/tez/staging
```
- 在**全部 hive 主机**上解压 tez 部署包
```bash
mkdir /opt/tez
tar zxf tez-0.9.2-minimal.tar.gz -C /opt/tez/
```
### 修改 yarn-site.xml
- 在**全部主机(包括 hadoop)**上执行如下操作
- 参考[在 $HADOOP_HOME/etc/hadoop/yarn-site.xml 中关闭 yarn 虚拟内存检查](/hdp2#修改 yarn-site.xml)
### 创建 tez-site.xml
- 在**全部主机(包括 hadoop)**上执行如下操作
- 创建 $HADOOP_HOME/etc/hadoop/tez-site.xml参考内容如下
```xml
<configuration>
<property>
<name>tez.lib.uris</name>
<type>string</type>
<value>hdfs://hdp-nn:8020/tez/tez-0.9.2.tar.gz</value>
</property>
</configuration>
```
### 修改 hive-site.xml
- 在**全部 hive 主机**上执行如下操作
- 参考[在 $HIVE_HOME/etc/hadoop/yarn-site.xml 中配置 tez staging 目录](/hive2#创建 hive-site.xml)
### 修改 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 set hive.execution.engine=tez;
```