一.搭建hadoop
第一步搭建好hadoop3.1版本,参考官方教程一步一步实现就好;
https://hadoop.apache.org/docs/r3.1.2/hadoop-project-dist/hadoop-common/SingleCluster.html
这里需要注意对应的hadoop版本,每个版本可能会有一些差别
二.tez安装
1.编译tez
http://tez.apache.org/install.html
在官方的tez安装过程中踩了坑,打包的过程如果直接使用
mvn clean package -DskipTests=true -Dmaven.javadoc.skip=true
编译出来的tez对应的jar包会出现版本不匹配的问题
下载0.9.2版本的源码http://www.apache.org/dyn/closer.lua/tez/0.9.2/
此处需要参考源码中的BUILDING.txt
另外因为部署的tez-ui会和hadoop交互,但是tez-0.9.2使用的是jersey 1.9版本,hadoop-3.1.2使用的是1.19版本,编译前需要将pom.xml中的版本修改为1.19版本;
需要有maven,在项目的根目录下执行
mvn clean package -DskipTests=true -Dhadoop.version=3.1.2 -Phadoop28 -P\!hadoop27 -Dmaven.javadoc.skip=true
环境依赖
编译之前需要安装proto 2.5,另外tez-ui模块打包的过程涉及到部分前端组件的安装,参考网上的例子也都能解决;
第一次编译的时间可能会比较长,需要下载的依赖包比较多
2.部署tez
将tez-dist目录下的tez-0.9.2.tar.gz放到hdfs /apps/tez-0.9.2目录下(这里官网提供了两种方法,可以直接使用mini包,并在tez-site.xml中Set tez.use.cluster.hadoop-libs to true),将minimal解压到本地目录
创建hdfs目录
hadoop fs -mkdir /apps
hadoop fs -mkdir /apps/tez-0.9.2
将tez压缩包放在hdfs建好的目录下
hadoop fs -put /path/tez-dist/target/tez-0.9.2.tar.gz /apps/tez-0.9.2/
将tez压缩包解压到部署主机的安装目录下
tar -xvf /path/tez-dist/target/tez-0.9.2-minimal.tar.gz -C /opt/tez-0.9.2
需要添加HADOOP_CLASSPATH变量,添加的作用是在hive启动的时候能够找到这些配置及jar包并加载初始化
export HADOOP_CLASSPATH=${TEZ_CONF_DIR}:${TEZ_JARS}/*:${TEZ_JARS}/lib/*
在hadoop配置目录下,配置tez-site.xml如下所示:
[root@wentjiang103 tez-0.9.2]# cat /opt/hadoop-3.1.2/etc/hadoop/tez-site.xml
<configuration>
<property>
<name>tez.lib.uris</name>
<value>${fs.defaultFS}/apps/tez-0.9.2/tez-0.9.2.tar.gz</value>
</property>
<property>
</configuration>
修改mapred-site.xml配置文件
Modify mapred-site.xml to change “mapreduce.framework.name” property from its default value of “yarn” to “yarn-tez”
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn-tez</value>
</property>
<property>
</configuration>
创建一个文件test.txt,随便写入内容,放到hdfs中
hadoop fs -put ./test.txt /input
由于在虚拟机中运行,资源比较小,需要将mapred-site.xml添加,否则会资源太少无法执行,
<property>
<name>mapreduce.map.memory.mb</name>
<value>512</value>
<description>The amount of memory to request from the scheduler for each
map task. If this is not specified or is non-positive, it is inferred from
mapreduce.map.java.opts and mapreduce.job.heap.memory-mb.ratio.
If java-opts are also not specified, we set it to 1024.
</description>
</property>
<property>
<name>mapreduce.reduce.memory.mb</name>
<value>512</value>
<description>The amount of memory to request from the scheduler for each
reduce task. If this is not specified or is non-positive, it is inferred
from mapreduce.reduce.java.opts and mapreduce.job.heap.memory-mb.ratio.
If java-opts are also not specified, we set it to 1024.
</description>
</property>
tez安装目录执行
hadoop jar tez-examples-0.9.2.jar orderedwordcount /input /output
虚拟机内存设置4G还是会报虚拟内存不足,把虚拟机内存修改为8G,可以正常运行
查看输出结果

至此,官方示例已经全部跑通
三.集成tez-ui
tez-ui的官网介绍
http://tez.apache.org/tez-ui.html
tez-ui的数据源介绍
http://tez.apache.org/tez_ui_user_data.html
tez-ui需要结合yarn的timeline使用,timeline提供了tez-ui的数据源
修改tez配置,tez-site.xml添加
<property>
<description>Enable Tez to use the Timeline Server for History Logging</description>
<name>tez.history.logging.service.class</name>
<value>org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService</value>
</property>
<property>
<description>URL for where the Tez UI is hosted</description>
<name>tez.tez-ui.history-url.base</name>
<value>http://<webserver-host:9999/tez-ui/</value>
</property>
注意tez.tez-ui.history-url.base需要填写tomcat部署的地址我本地的为http://wentjiang101:8080/tez-ui-0.9.2/,需要修改成你的配置;
将源码目录下打包的war包apache-tez-0.9.2-src/tez-ui/target/tez-ui-0.9.2.war放在tomcat /opt/apache-tomcat-8.5.47/webapps目录下,启动
timeline除了tez-ui网站上的配置之外还需要添加,下边的配置,才能保存历史日志,否则timeline默认不持久化日志
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
前端配置修改
前端打包的时候需要修改Timeline Server URL和Resource Manager UI URL
在scripts/configs.env 中修改这两个配置为部署的timeline地址和RM地址,
// timelineBaseUrl: 'http://localhost:8188',
// RMWebUrl: 'http://localhost:8088',
这里需要注意,前端的//不生效,所以需要将//里的内容直接修改为你的地址;
不是好timeline和tez-ui之后,我们尝试执行hive on tez命令,发现出现了NoSuchMethodError错误
org.apache.hadoop.service.ServiceStateException: java.lang.NoSuchMethodError: com.sun.jersey.api.client.ClientResponse.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType;
查看引用包发现,hadoop引用的jersey是1.19版本,tez引用的是1.9版本,这里需要将tez引用的1.9替换为1.19版本,重新打包部署即可
这样就能愉快的使用tez-ui了

三表join做查询
select * from student join bag join grade where student.id = bag.studentId and student.id = grade.studentId
另外tez-ui是有两个tab页面,第二个tab页面hive query需要在hive-site.xml中添加一些配置,参考ATSHook的描述即可
四.更详尽的内容
参考我的另一篇博客:https://blog.youkuaiyun.com/lo085213/article/details/104753170
本文详细介绍了如何从零开始搭建Hadoop集群,并成功安装和配置Tez引擎,包括解决版本冲突、编译和部署Tez,以及集成Tez-UI进行数据处理和可视化监控。同时,还分享了解决常见问题的经验。
956

被折叠的 条评论
为什么被折叠?



