Hive 使用TEZ引擎导致连接Hive SHELL慢的问题

在使用HDP Hadoop版本时,Ambari界面允许选择Hive执行引擎是MapReduce还是TEZ,如下图所示
这里写图片描述

使用TEZ作为Hive执行引擎来替代MapReduce,可以在很多场景上实现更好的效率提高,然后使用TEZ作为默认引擎也会导致一些问题。最近就碰到这样的场景,客户使用TEZ作为执行引擎,在计算过程中确实比使用默认的MapReduce快很多,但遇到的一个问题是:每次总要花10~20秒连接进入Hive SHELL命令行,在虚拟机环境中有时候更严重,需要等上几分钟不等。

经过试验,发现如果把Hive默认的执行引擎改成MapReduce后,连接Hive SHELL会变的快很多。于是最终采用的work around方法是:从ambari中将Hive默认执行引擎修改为MapReduce,并在连接Hive SHELL后执行set hive.execution.engine=tez,将执行引擎切换为TEZ。

至于为什么使用TEZ导致连接Hive SHELL慢的问题,我们找到了这篇文章, https://community.hortonworks.com/questions/1201/hive-cli-unresponsive.html

文章中有段描述如下,

***One thing to check is if they are using tez. If they are, it could be possible that they do not have any capacity on their YARN cluster to launch AM. So the Hive CLI waits indefinitely to launch an AM. One thing they can do to alleviate this is to launch hive cli as “hive -hiveconf hive.execution.engine=mr”.
Its not that MR gets resources, Tez just pre-allocates resources, it starts a YARN application as soon as you invoke the Hive CLI. In case of MR a YARN application is launched only when its required by the executing query. This is a performance optimization in Hive on Tez saving the user the overhead of launching a AM everytime a new query is run in the same Hive CLI session.*

从以上解释我们了解到,使用TEZ作为Hive默认执行引擎时,需要在调用Hive CLI的时候启动YARN应用,预分配资源,这需要花一些时间,而使用MapReduce作为执行引擎时是在执行语句的时候才会去启用YARN应用。
如果需要解决使用TEZ连接慢的问题,可以使用hive -hiveconf hive.execution.engine=mr作为一种替代方案去启动Hive SHELL的连接。

猜你喜欢

转载自blog.csdn.net/post_yuan/article/details/80938287
今日推荐