hive3.x安装tez
一 、编译Tez0.10.1
- 下载tez的src.tar.gz源码包
新版的tez0.10.1需要在github下载,附链接 https://github.com/apache/tez - 需要在pom.xml中更改hadoop.version属性的值,以匹配所使用的hadoop分支的版本。我这里是Apache Hadoop 3.1.3
vim pom.xml修改 - 修改guava版本hadoop 3.1.3使用的guava版本是27.0-jre
- 安装git—>yum install -y git 和maven 为编译做准备
- 将tez-ui编译注释掉
maven安装:
-
安装wget命令 yum -y install wget -
下载maven安装包 wget http://mirrors.cnnic.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz -
解压maven安装包 tar -zxvf apache-maven-3.5.4-bin.tar.gz -C 安装目录 -
配置maven vi /etc/profile 在配置文件配置
export MAVEN_HOME=/opt/module/apache-maven-3.5.4
export PATH=$PATH:$MAVEN_HOME/bin
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
</mirrors>
- 安装编译工具
yum -y install autoconf automake libtool cmake ncurses-devel openssl-devel lzo-devel zlib-devel gcc gcc-c++
- 可以先安装protobuf,下载链接https://github.com/protocolbuffers/protobuf/tags
根据hadoop的lib中可以确定版本为2.5.0,下好源码包后,解压,并且编译protobuf 2.5.0 如果报错没权限,可以使用root编译
tar -zxvf protobuf-2.5.0.tar.gz -C /usr/local/
cd protobuf-2.5.0/
./autogen.sh
vim autogen.sh
curl -L https://github.com/google/googletest/archive/release-1.5.0.tar.gz | tar zx
mv googletest-release-1.5.0 gtest
./configure --prefix=/usr/local/protobuf
make
make install
- 编译Tez
mvn clean package -DskipTests=true -Dmaven.javadoc.skip=true
- 编译成功后,包会在/opt/module/tez-branch-0.10.1/tez-dist/target目录下,我们需要的是这连两个
二、为Hive配置Tez了
1.将tez安装包拷贝到集群,并解压tar包,注意解压的是minimal
mkdir /opt/module/tez
tar -zxvf /opt/module/tez-branch-0.10.1/tez-dist/target/tez-0.10.1-minimal.tar.gz -C /opt/module/tez
2.上传tez依赖到HDFS
hadoop fs -mkdir /tez(集群创建/tez路径,然后再上传,注意路径)
hadoop fs -put /opt/module/tez-branch-0.10.1/tez-dist/target/tez-0.10.1.tar.gz /tez
3.新建tez-site.xml在$HADOOP_HOME/etc/hadoop/路径下(注意,不要放在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.10.1-SNAPSHOT.tar.gz</value>
</property>
<property>
<name>tez.use.cluster.hadoop-libs</name>
<value>true</value>
</property>
<property>
<name>tez.am.resource.memory.mb</name>
<value>1024</value>
</property>
<property>
<name>tez.am.resource.cpu.vcores</name>
<value>1</value>
</property>
<property>
<name>tez.container.max.java.heap.fraction</name>
<value>0.4</value>
</property>
<property>
<name>tez.task.resource.memory.mb</name>
<value>1024</value>
</property>
<property>
<name>tez.task.resource.cpu.vcores</name>
<value>1</value>
</property>
</configuration>
4.修改Hadoop环境变量
vim $HADOOP_HOME/etc/hadoop/shellprofile.d/tez.sh
添加Tez的Jar包相关信息,如果最后没成功,把这个配置写example.sh中也可以
hadoop_add_profile tez
function _tez_hadoop_classpath
{
hadoop_add_classpath "$HADOOP_HOME/etc/hadoop" after
hadoop_add_classpath "/opt/module/tez/*" after
hadoop_add_classpath "/opt/module/tez/lib/*" after
}
5.到hive的hive-site.xml中添加参数
<property>
<name>hive.tez.container.size</name>
<value>1024</value>
</property>
如果不参加这个参数,tez任务会一直卡主: yarn的container日志可以看到报错: Invalid resource request, requested resource type=[memory-mb] < 0 or greater than maximum allowed allocation. Requested resource=<memory:-1, vCores:1>, maximum allowed allocation=<memory:4096, vCores:4>, please note that maximum allowed allocation is calculated by scheduler based on maximum resource of registered NodeManagers, which might be less than configured maximum allocation=<memory:4096, vCores:4>
6.在hive-env.sh中添加tez的路径
export TEZ_HOME=/opt/module/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=/opt/module/hadoop-3.1.3/share/hadoop/common/hadoop-lzo-0.4.21-SNAPSHOT.jar$TEZ_JARS
这样就可以在hive跑tez任务了
参考链接:https://blog.csdn.net/Hello_Java2018/article/details/106036782
|