1. 程式人生 > >Hive 使用TEZ引擎導致連線Hive SHELL慢的問題

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。

文章中有段描述如下,

***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的連線。