一、文档目的
近期在CDH 6.1.x中部署Tez 0.9.1,踩到很多坑,主要还是CDH集群版本较高,导致所用教程和实际部署不一致(自己挖的坑),希望给大家一个参考。
1.1 文章概述
- 环境准备及编译
- Tez安装与测试
-
1.2 基础环境
CM和CDH版本为 6.3.2
- Redhat 7.6
- JDK 1.8.0_181
- Hive版本为2.4.0
- Tez版本为0.9.1
二、基础环境准备
基础环境准备,用于编译Tez,包括JDK、Maven、Protobuf,请大家按需安装,具体如下:
- JDK8或更高版本
- Maven3或更高版本
- Protobuf2.5.0(注意:必须为这个版本)
1.JDK安装
推荐rpm包安装,无需配置环境变量,如需配置环境变量如下所示:
export JAVA_HOME=/usr/java/jdk1.8.0_181
export PATH=$JAVA_HOME/bin:$PATH
验证Java环境
source /etc/profile
java -version
2.maven安装
export MVN_HOME=/usr/local/maven
export PATH=$MVN_HOME/bin:$PATH
验证maven环境
source /etc/profile
mvn -v
3.protobuf-2.5.0安装
找到对应资源,下载压缩包。
解压
tar -zxvf protobuf-2.5.0.tar.gz
编译安装
cd protobuf-2.5.0
yum -y install openssl-devel
yum -y install popt-devel
yum -y install gcc
yum -y install gcc-c++
./configure
make & make install
protoc --version #验证是否安装成功
三、Tez安装与测试
1.下载源码包
http://tez.apache.org/releases/apache-tez-0-9-1.html
2.解压
tar -zxvf apache-tez-0.9.1-src.tar.gz
3.修改pom.xml
将Hadoop的依赖修改为CDH提供的依赖:
<properties>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
<clover.license>${user.home}/clover.license</clover.license>
<hadoop.version>3.0.0-cdh6.3.2</hadoop.version>
<jetty.version>6.1.26</jetty.version>
<netty.version>3.6.2.Final</netty.version>
<pig.version>0.13.0</pig.version>
<javac.version>1.8</javac.version>
<slf4j.version>1.7.10</slf4j.version>
<enforced.java.version>[${javac.version},)</enforced.java.version>
<distMgmtSnapshotsId>apache.snapshots.https</distMgmtSnapshotsId>
<distMgmtSnapshotsName>Apache Development Snapshot Repository</distMgmtSnapshotsName>
<distMgmtSnapshotsUrl>https://repository.apache.org/content/repositories/snapshots</distMgmtSnapshotsUrl>
<distMgmtStagingId>apache.staging.https</distMgmtStagingId>
<distMgmtStagingName>Apache Release Distribution Repository</distMgmtStagingName>
<distMgmtStagingUrl>https://repository.apache.org/service/local/staging/deploy/maven2</distMgmtStagingUrl>
<failIfNoTests>false</failIfNoTests>
<protobuf.version>2.5.0</protobuf.version>
<protoc.path>${env.PROTOC_PATH}</protoc.path>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scm.url>scm:git:https://git-wip-us.apache.org/repos/asf/tez.git</scm.url>
<build.time>${maven.build.timestamp}</build.time>
<frontend-maven-plugin.version>1.4</frontend-maven-plugin.version>
<findbugs-maven-plugin.version>3.0.1</findbugs-maven-plugin.version>
<javadoc-maven-plugin.version>2.10.4</javadoc-maven-plugin.version>
<shade-maven-plugin.version>2.4.3</shade-maven-plugin.version>
</properties>
添加Cloudera的Maven仓库地址:
<repositories>
<repository>
<id>${distMgmtSnapshotsId}</id>
<name>${distMgmtSnapshotsName}</name>
<url>${distMgmtSnapshotsUrl}</url>
</repository>
<!-- 加这一段 -->
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
<name>Cloudera Repositories</name>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven2-repository.atlassian</id>
<name>Atlassian Maven Repository</name>
<url>https://maven.atlassian.com/repository/public</url>
<layout>default</layout>
</pluginRepository>
<pluginRepository>
<id>${distMgmtSnapshotsId}</id>
<name>${distMgmtSnapshotsName}</name>
<url>${distMgmtSnapshotsUrl}</url>
<layout>default</layout>
</pluginRepository>
<!-- 加这一段 -->
<pluginRepository>
<id>cloudera</id>
<name>Cloudera Repositories</name>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</pluginRepository>
</pluginRepositories>
修改jersey-client的版本到1.19
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
因为jersey-client 1.9 版本,使用编译生成的tez-0.9.1.tar.gz上传到hdfs后,会出现以下报错:
java.lang.NoSuchMethodError: com.sun.jersey.api.client.ClientResponse.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType;
4.修改tez-mapreduce模块下的源码文件(先编译tez查看是否需要)
tez-mapreduce编译时,报ApplicationReport.newInstance() 89行异常,使用另一个方法newInstance()方法。
vi tez-mapreduce/src/main/java/org/apache/tez/mapreduce/client/NotRunningJob.java
# 增加long launchTime参数(下面代码中三个0中,中间一个0)
return ApplicationReport.newInstance(unknownAppId, unknownAttemptId, "N/A", "N/A", "N/A", "N/A", 0, null, YarnApplicationState.NEW, "N/A", "N/A", 0, 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f, "TEZ_MRR", null);
5.编译
mvn clean package -DskipTests=true -Dmaven.javadoc.skip=true
6.部署至HDFS
tez-0.9.1.tar.gz相对路径为根目录下tez-dist/target
sudo -u hdfs hdfs dfs -mkdir -p /engine/tez-0.9.2/
sudo -u hdfs hdfs dfs -put tez-0.9.2.tar.gz /engine/tez-0.9.2/
sudo -u hdfs hdfs dfs -chmod -R 777 /engine/tez-0.9.2/
sudo -u hdfs hdfs dfs -chown -R tez:tez /engine/tez-0.9.2/
sudo -u hdfs hdfs dfs -ls /engine/tez-0.9.2/
7.创建tez-site.xml,配置客户端
在cdh包路径下创建tez包,我的路径是/opt/cloudera/parcels/CDH/lib/tez
mkdir /opt/cloudera/parcels/CDH/lib/tez
新建conf文件夹存放tez-site.xml
mkdir /opt/cloudera/parcels/CDH/lib/tez/conf
vim /opt/cloudera/parcels/CDH/lib/tez/conf/tez-site.xml
<configuration>
<property>
<name>tez.lib.uris</name>
<value>${fs.defaultFS}/engine/tez-0.9.1/tez-0.9.1.tar.gz</value> </property>
<property>
<name>tez.use.cluster.hadoop-libs</name>
<value>false</value>
</property>
</configuration>
将tez-0.9.1-minimal(相对路径为根目录下tez-dist/target/)文件夹下的jar及lib下的jar拷贝到tez中
cd tez-dist/target/tez-0.9.1-minimal
cp *.jar /opt/cloudera/parcels/CDH/lib/tez
cp -r lib /opt/cloudera/parcels/CDH/lib/tez
从/opt/cloudera/parcels/CDH/jars中拷贝kryo-2.22.jar到tez文件夹下的lib文件夹下,否则会出现以下异常
java.lang.ClassNotFoundException: com.esotericsoftware.kryo.Serializer
避免kryo的错误
cd /opt/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/lib/hive/auxlib
mv hive-exec-2.1.1-cdh6.3.2-core.jar hive-exec-2.1.1-cdh6.3.2-core.jar.bak
mv hive-exec-core.jar hive-exec-core.jar.bak
tez/lib中包含slf4j的jar包,会打印较多日志,可以在客户端中去掉slf4j-api-1.7.10.jar、slf4j-log4j12-1.7.10.jar这两个jar包,减少日志打印,在yarn/tez-ui中查看日志。
解决找不到类解决完感
cd /etc/hadoop/conf
vim hadoop-env.sh
在最后添加
export TEZ_HOME=/opt/cloudera/parcels/CDH/lib/tez
for jar in `ls $TEZ_HOME | grep jar`; do
export HADOOP_CALSSPATH=$HADOOP_CLASSPATH:$TEZ_HOME/$jar
done
for jar in `ls $TEZ_HOME/lib`; do
export HADOOP_CALSSPATH=$HADOOP_CLASSPATH:$TEZ_HOME/lib/$jar
done
将以上内容分发到所有节点。
将/opt/cloudera/parcels/CDH/lib/tez分发到所有节点。
scp -r /opt/cloudera/parcels/CDH/lib/tez node:/opt/cloudera/parcels/CDH/lib/
8.配置hive环境变量
HADOOP_CLASSPATH=/opt/cloudera/parcels/CDH/lib/tez/conf:/opt/cloudera/parcels/CDH/lib/tez/*:/opt/cloudera/parcels/CDH/lib/tez/lib/*
9.测试
# sudo -u hive hive
hive> set hive.tez.container.size=3020;
hive> set hive.execution.engine=tez;
hive> select count(*) from tableName;
总结
- 在CDH集群中集成Tez时需要进行重新编译,以避免Jar包版本不一致导致的问题。
- CDH 不推荐用新版。
以上内容,仅个人实践,欢迎大家一块讨论。下一篇,进行tez-ui的部署说明。
参考链接:
http://tez.apache.org/install.html
https://cloud.tencent.com/developer/article/1349504
https://blog.csdn.net/sinat_37690778/article/details/80594571
https://blog.csdn.net/qq_41041447/article/details/114523496