1. 下載
下載地址:https://dlcdn.apache.org/tez/,選擇帶-bin
的,此處下載apache-tez-0.10.1-bin.tar.gz
2. 解壓
hive在哪個節點上,就解壓到哪個節點
tar -zxvf apache-tez-0.10.1-bin.tar.gz -C /opt/
# 重命名(可選)
mv /opt/apache-tez-0.10.1-bin/ /opt/tez-0.10.1/
3. 上傳tez包到HDFS
tez解壓到了hive節點上,那hive自然是可以使用到tez引擎,但在Hadoop集羣上執行任務的時候,所有的節點都需要進行計算,因此也需要將tez上傳到hdfs上,供其他節點使用
hdfs dfs -mkdir /tez
hdfs dfs -put ./apache-tez-0.10.1-bin.tar.gz /tez
查看hdfs確認上傳成功
4. 配置tez-site.xml
在hive
的conf
目錄下新建tez-site.xml
,內容爲如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- hdfs上tez包的路徑 -->
<property>
<name>tez.lib.uris</name>
<value>${fs.defaultFS}/tez/apache-tez-0.10.1-bin.tar.gz</value>
</property>
<!-- tez可使用集羣jar包 -->
<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>
5. 配置hive-env.sh
hive
的conf
目錄自帶一個hive-env.sh.template
,複製一個即可
cp hive-env.sh.template hive-env.sh
在hive-env.sh
末尾追加一下內容:
export TEZ_HOME=/opt/tez-0.10.1 # 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=${TEZ_JARS:1}
6. 修改hive-site.xml
修改hive引擎爲tez,修改tez容器大小
<property>
<name>hive.execution.engine</name>
<value>tez</value>
</property>
<property>
<name>hive.tez.container.size</name>
<value>1024</value>
</property>
7. 修改yarn-site.xml
關閉yarn的虛擬內存檢查,否則tez無法執行任務
<!-- 關閉yarn虛擬內存檢查 -->
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
記得要把所有hadoop節點的yarn-site.xml
都同步
8. 重啓hadoop集羣
mapred --daemon stop historyserver && stop-yarn.sh && stop-dfs.sh
start-dfs.sh && start-yarn.sh && mapred --daemon start historyserver
9. 測試tez是否切換成功
create table student(id string, name string);
insert into student values('1001', 'hello');
tez切換正常
10. 其它情況
- 如果hive執行任務一直處於
INITED
狀態,看是不是tez容器太大了 - yarn執行任務過多佔滿資源,通過
yarn app -list
,yarn app -kill <applicationId>
把任務先kill掉再測試tez引擎