当前位置:网站首页>【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
2022-07-06 11:50:00 【华为云】
MRS支持在大数据存储容量大、计算资源需要弹性扩展的场景下,用户将数据存储在OBS服务中,使用MRS集群仅做数据计算处理的存算分离模式。
Flink是一个批处理和流处理结合的统一计算框架,其核心是一个提供了数据分发以及并行化计算的流数据处理引擎。它的最大亮点是流处理,是业界最顶级的开源流处理引擎。
本文将向您介绍如何在MRS集群中运行Flink作业来处理OBS中存储的数据。

在本示例中,我们使用MRS集群内置的Flink WordCount作业程序,来分析OBS文件系统中保存的源数据,以统计源数据中的单词出现次数。
当然您也可以获取MRS服务样例代码工程,参考Flink开发指南开发其他Flink流作业程序。
本案例基本操作流程如下所示:

创建MRS集群
本文以购买MRS 3.1.0版本的集群为例,集群未开启Kerberos认证。
在本示例中,由于我们要分析处理OBS文件系统中的数据,因此在集群的高级配置参数中要为MRS集群绑定IAM权限委托,使得集群内组件能够对接OBS并具有对应文件系统目录的操作权限。
您可以直接选择系统默认的“MRS_ECS_DEFAULT_AGENCY”,也可以自行创建其他具有OBS文件系统操作权限的自定义委托。

例如客户端安装目录为“/opt/client”。
准备测试数据
在创建Flink作业进行数据分析前,我们需要在提前准备待分析的测试数据,并将该数据上传至OBS文件系统中。
本地创建一个“mrs_flink_test.txt”文件,例如文件内容如下:
This is a test demo for MRS Flink. Flink is a unified computing framework that supports both batch processing and stream processing. It provides a stream data processing engine that supports data distribution and parallel computing.
在云服务列表中选择“存储 > 对象存储服务”,登录OBS管理控制台。
单击“并行文件系统”,创建一个并行文件系统,并上传测试数据文件。
例如创建的文件系统名称为“mrs-demo-data”,单击系统名称,在“文件”页面中,新建一个文件夹“flink”,上传测试数据至该目录中。
则本示例的测试数据完整路径为“obs://mrs-demo-data/flink/mrs_flink_test.txt”。
上传数据分析应用程序。
使用管理台界面直接提交作业时,将已开发好的Flink应用程序jar文件也可以上传至OBS文件系统中,或者MRS集群内的HDFS文件系统中。
本示例中我们使用MRS集群内置的Flink WordCount样例程序,可从MRS集群的客户端安装目录中获取,即“/opt/client/Flink/flink/examples/batch/WordCount.jar”。
将“WordCount.jar”上传至“mrs-demo-data/program”目录下。
创建并运行Flink作业
方式1:在控制台界面在线提交作业。
登录MRS管理控制台,单击MRS集群名称,进入集群详情页面。
在集群详情页的“概览”页签,单击“IAM用户同步”右侧的“单击同步”进行IAM用户同步。
- 单击,进入 页签。
- 单击 “添加”,添加一个Flink作业。
作业类型:Flink
作业名称:自定义,例如flink_obs_test。
执行程序路径:本示例使用Flink客户端的WordCount程序为例。
运行程序参数:使用默认值。
执行程序参数:设置应用程序的输入参数,“input”为待分析的测试数据,“output”为结果输出文件。
例如本示例中,我们设置为“--input obs://mrs-demo-data/flink/mrs_flink_test.txt --output obs://mrs-demo-data/flink/output”。
- 服务配置参数:使用默认值即可,如需手动配置作业相关参数,可参考 运行Flink作业。
- 确认作业配置信息后,单击 “确定”,完成作业的新增,并等待运行完成。
方式2:通过集群客户端提交作业。
- 使用 root用户登录集群客户端节点,进入客户端安装目录。
su - ommcd /opt/clientsource bigdata_env
执行以下命令验证集群是否可以访问OBS。
hdfs dfs -ls obs://mrs-demo-data/flink
提交Flink作业,指定源文件数据进行消费。
flink run -m yarn-cluster /opt/client/Flink/flink/examples/batch/WordCount.jar --input obs://mrs-demo-data/flink/mrs_flink_test.txt --output obs://mrs-demo/data/flink/output2
执行后结果类似如下:
...Cluster started: Yarn cluster with application id application_1654672374562_0011Job has been submitted with JobID a89b561de5d0298cb2ba01fbc30338bcProgram execution finishedJob with JobID a89b561de5d0298cb2ba01fbc30338bc has finished.Job Runtime: 1200 ms
查看作业执行结果
作业提交成功后,登录MRS集群的FusionInsight Manager界面,选择“集群 > 服务 > Yarn”。
单击“ResourceManager WebUI”后的链接进入Yarn Web UI界面,在Applications页面查看当前Yarn作业的详细运行情况及运行日志。
等待作业运行完成后,在OBS文件系统中指定的结果输出文件中可查看数据分析输出的结果。
下载“output”文件到本地并打开,可查看输出的分析结果。
a 3and 2batch 1both 1computing 2data 2demo 1distribution 1engine 1flink 2for 1framework 1is 2it 1mrs 1parallel 1processing 3provides 1stream 2supports 2test 1that 2this 1unified 1
使用集群客户端命令行提交作业时,若不指定输出目录,在作业运行界面也可直接查看数据分析结果。
Job with JobID xxx has finished.Job Runtime: xxx msAccumulator Results:- e6209f96ffa423974f8c7043821814e9 (java.util.ArrayList) [31 elements](a,3)(and,2)(batch,1)(both,1)(computing,2)(data,2)(demo,1)(distribution,1)(engine,1)(flink,2)(for,1)(framework,1)(is,2)(it,1)(mrs,1)(parallel,1)(processing,3)(provides,1)(stream,2)(supports,2)(test,1)(that,2)(this,1)(unified,1)
边栏推荐
- 关于图像的读取及处理等
- 接雨水问题解析
- Interview assault 63: how to remove duplication in MySQL?
- (3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of
- Chic Lang: attributeerror: partially initialized module 'CV2' has no attribute 'GAPI_ wip_ gst_ GStreamerPipe
- VMware virtual machine cannot open the kernel device "\.\global\vmx86"
- Live broadcast today | the 2022 Hongji ecological partnership conference of "Renji collaboration has come" is ready to go
- Selenium advanced operations
- Learn to explore - use pseudo elements to clear the high collapse caused by floating elements
- Blue Bridge Cup microbial proliferation C language
猜你喜欢
It's super detailed in history. It's too late for you to read this information if you want to find a job
通俗的讲解,带你入门协程
zabbix 代理服务器 与 zabbix-snmp 监控
深度剖析原理,看完这一篇就够了
Analysis of rainwater connection
《数字经济全景白皮书》保险数字化篇 重磅发布
蓝桥杯 微生物增殖 C语言
Pay attention to the partners on the recruitment website of fishing! The monitoring system may have set you as "high risk of leaving"
Hudi vs Delta vs Iceberg
凤凰架构3——事务处理
随机推荐
Finally, there is no need to change a line of code! Shardingsphere native driver comes out
usb host 驱动 - UVC 掉包
Interpretation of Dagan paper
[pytorch] yolov5 train your own data set
LeetCode_ Gray code_ Medium_ 89. Gray code
How to do smoke test
It's enough to read this article to analyze the principle in depth
Simple application of VBA script in Excel
MySql必知必会学习
Application of clock wheel in RPC
深入浅出,面试突击版
腾讯T3大牛手把手教你,大厂内部资料
Hudi vs Delta vs Iceberg
社招面试心得,2022最新Android高频精选面试题分享
[play with Linux] [docker] MySQL installation and configuration
学习探索-使用伪元素清除浮动元素造成的高度坍塌
POJ3617 Best Cow Line 馋
Swagger2 reports an error illegal DefaultValue null for parameter type integer
Dom 操作
ZABBIX proxy server and ZABBIX SNMP monitoring