Hive配置Tez引擎踩坑
阅读原文时间:2023年07月08日阅读:1

框架版本

Hadoop 2.7.7

Hive 2.3.7

Tez 0.9.2

保证hadoop集群启动,hive元数据服务启动

上传tez到HDFS

tar -zxvf apache-tez-0.9.2-bin.tar.gz
mv apache-tez-0.9.2-bin tez-0.9.2
hdfs dfs -mkidr /tez
hdfs dfs -put tez-0.9.2 /tez
#这里tez可以直接上文件,也可以上传解压后的文件

配置hive-env.sh

export TEZ_HOME=/opt/tez-0.9.2    #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 HIVE_AUX_JARS_PATH=
#配置外部Jar包,如LZO等

配置hive-site.xml

  </property>
    <property>
    <name>hive.execution.engine</name>
    <value>tez</value>
  </property>

最后在hive/conf下创建并配置tez-site.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
    <name>tez.lib.uris</name>
    <value>${fs.defaultFS}/tez/tez-0.9.2,${fs.defaultFS}/tez/tez-0.9.2/lib</value>
        <!--  指定依赖位置  -->
</property>
<property>
    <name>tez.lib.uris.classpath</name>
    <value>${fs.defaultFS}/tez/tez-0.9.2,${fs.defaultFS}/tez/tez-0.9.2/lib</value>
        <!--  实测这项配置非必须  -->
</property>
<property>
     <name>tez.use.cluster.hadoop-libs</name>
     <value>true</value>
</property>
<property>
     <name>tez.history.logging.service.class</name>
     <value>org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService</value>
</property>
</configuration>

启动hive

java.lang.NoClassDefFoundError: org/apache/tez/dag/api/SessionNotRunning

显示会话服务无法开启

解决方法:将 tez-0.9.7和 tez-0.9.7/lib下Jar包复制到 hive/lib下即可解决

或者使用这套思路应该也可以解决 Exception in thread main java.lang.NoClassDefFoundError: org/apache/tez/dag/api/TezConfiguration

再次启动hive,跳出以下异常,显示找不到tez.lib.uris即tez-site.xml位置

org.apache.tez.dag.api.TezUncheckedException: Invalid configuration of tez jars, tez.lib.uris is not defined in the configuration

解决方法:保证 /hive/conf 或/haoodp 2.7.7/etc/hadoop 下有编辑好的tez-site.xml文件即可