原因:由于/opt/module/hive/conf/hive-env.sh未正确配置,本地客户端找不到tez的jar包
报错信息:Error running query: java.lang.NoClassDefFoundError: org/apache/tez/runtime/api/Event
准备两个Tez文件:
tez-0.10.1- SNAPSHOT-minimal.tar.gz(hive客户端使用)
tez-0.10.1- SNAPSHOT.tar.gz(yarn集群使用)
链接:https://pan.baidu.com/s/1ji_kxoEvNwdZbvOurK7UOQ 提取码:d26j
基础依赖及环境变量参数:
Centos 7.5
Hadoop 3.1.3
JDK 1.8.0_212
Hive 3.1.2
JAVA_HOME=/opt/module/jdk1.8.0_212
HADOOP_HOME=/opt/module/hadoop-3.1.3
HIVE_HOME=/opt/module/hive
1.将 tez-minimal安装包拷贝到集群其中一台主机,并解压 tar 包
[atguigu@hadoop102 software]$ mkdir /opt/module/tez
[atguigu@hadoop102 software]$ tar -zxvf /opt/software/tez-0.10.1-SNAPSHOT-minimal.tar.gz -C /opt/module/tez
2.上传 tez 依赖到 HDFS
[atguigu@hadoop102 software]$ hadoop fs -mkdir /tez
[atguigu@hadoop102 software]$ hadoop fs -put /opt/software/tez-0.10.1-SNAPSHOT.tar.gz /tez
3.新建 tez-site.xml,并分发到集群每台主机
[atguigu@hadoop102 software]$ vim $HADOOP_HOME/etc/hadoop/tez-site.xml
添加如下:
<configuration>
<property>
<name>tez.lib.uris</name>
<value>${fs.defaultFS}/tez/tez-0.10.1-SNAPSHOT.tar.gz</value>
</property>
<property>
<name>tez.use.cluster.hadoop-libs</name>
<value>true</value>
</property>
<property>
<name>tez.am.resource.memory.mb</name>
<value>1024</value>
</property>
<property>
<name>tez.am.resource.cpu.vcores</name>
<value>1</value>
</property>
<property>
<name>tez.container.max.java.heap.fraction</name>
<value>0.4</value>
</property>
<property>
<name>tez.task.resource.memory.mb</name>
<value>1024</value>
</property>
<property>
<name>tez.task.resource.cpu.vcores</name>
<value>1</value>
</property>
</configuration>
分发tez-site.xml:
# 使用自定义分发脚本
[atguigu@hadoop102 software]$ xsync $HADOOP_HOME/etc/hadoop/tez-site.xml
# 或者手动scp到另外两台
[atguigu@hadoop102 software]$ scp $HADOOP_HOME/etc/hadoop/tez-site.xml
atguigu@hadoop103:/opt/module/hadoop-3.1.3/etc/hadoop/tez-site.xml
[atguigu@hadoop102 software]$ scp $HADOOP_HOME/etc/hadoop/tez-site.xml
atguigu@hadoop104:/opt/module/hadoop-3.1.3/etc/hadoop/tez-site.xml
# 正常情况,hadoop配置修改后就可以重启集群了,此处重启动作放在最后统一操作
4.修改 Hadoop 的jar包环境变量脚本hive-env.sh
# 此处不用重启,作用是启动hive的时候,会自动去寻找tez的jar包
[atguigu@hadoop102 software]$ vim $HADOOP_HOME/etc/hadoop/conf/hive-env.sh
添加 Tez 的 Jar 包相关信息
# 写你的 tez 的解压目录
export TEZ_HOME=/opt/module/tez
export TEZ_JARS=""
for jar in `ls $TEZ_HOME |grep jar`; do
export TEZ_JARS=$TEZ_JARS:$TEZ_HOME/$jar
done
for jar in `ls $TEZ_HOME/lib`; do
export TEZ_JARS=$TEZ_JARS:$TEZ_HOME/lib/$jar
done
export
TEZ_JARS=${TEZ_JARS:1}
HIVE_AUX_JARS_PATH=$TEZ_JARS
5.修改 Hive 的计算引擎
[atguigu@hadoop102 software]$ vim $HIVE_HOME/conf/hive-site.xml
添加:
<property>
<name>hive.execution.engine</name>
<value>tez</value>
</property>
<property>
<name>hive.tez.container.size</name>
<value>1024</value>
</property>
6.解决日志 Jar 包冲突
[atguigu@hadoop102 software]$ mv /opt/module/tez/lib/slf4j-log4j12-1.7.10.jar
/opt/module/tez/lib/slf4j-log4j12-1.7.10.jar.bak
7.重启hadoop集群和hive的服务
# 此处为自定义启停脚本
[atguigu@hadoop102 software]$ myhadoop.sh stop
[atguigu@hadoop102 software]$ myhadoop.sh start
[atguigu@hadoop102 software]$ hiveservices.sh stop
[atguigu@hadoop102 software]$ hiveservices.sh start