Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ MapReduce Service/ Best Practices/ Data Analytics/ Using Flink Jobs to Process OBS Data

Using Flink Jobs to Process OBS Data

Updated on 2024-11-12 GMT+08:00

Application Scenarios

MRS supports decoupled storage and compute in scenarios where a large storage capacity is required and compute resources need to be scaled on demand. This allows you to store your data in OBS and use an MRS cluster only for data computing.

This practice instructs you on how to run Flink jobs in an MRS cluster to process data stored in OBS.

Solution Architecture

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. Flink features stream processing and is a top open-source stream processing engine in the industry.

Flink provides high-concurrency pipeline data processing, millisecond-level latency, and high reliability, making it suitable for low-latency data processing.

In this example, the Flink WordCount job program built in the MRS cluster is used to analyze the source data stored in the OBS file system and compute the frequency of words in the source data.

You can also obtain MRS sample code project and develop other Flink stream job programs by referring to Flink Development Guide.

Procedure

The operation process is as follows:

Step 1: Creating an MRS Cluster

Create and purchase an MRS cluster that contains the Flink component. For details, see Buying a Custom Cluster.

NOTE:

In this practice, an MRS 3.1.0 cluster with Kerberos authentication disabled is used as an example.

In this example, before you analyze data stored in OBS, bind an IAM agency to the MRS cluster so that cluster components can connect to the OBS file system and have operation permissions on file system directories.

You can select the default MRS_ECS_DEFAULT_AGENCY agency or create a custom agency that has the permission to operate the OBS file system.

After the cluster is purchased, install the cluster client on any node of the cluster as user omm. For details, see Installing and Using the Cluster Client.

Assume that the client is installed in /opt/client.

Step 2: Preparing Test Data

Before you create a Flink job for data analysis, prepare test data to be analyzed and upload the data to OBS.

  1. Create a file named mrs_flink_test.txt on your local PC. For example, the file content is as follows:

    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. 

  2. Choose Service List > Storage > Object Storage Service.
  3. On the OBS management console that is displayed, choose Parallel File Systems in the navigation pane on the left. On the page displayed, click Create Parallel File System and set required parameters to create a parallel file system. After the system is created, upload the test data to it.

    For example, if the created file system is named mrs-demo-data, click the system name, and click the Files tab. On this tab page, click Create Folder to create a folder named flink and upload the test data to the folder.

    In this example, the complete path of the test data is obs://mrs-demo-data/flink/mrs_flink_test.txt.

    Figure 1 Uploading test data

  4. (Optional) Uploading Data Analysis Applications

    You can upload the JAR files of the Flink applications developed by yourself to OBS or HDFS of the MRS cluster.

    In this example, the Flink WordCount sample program built in the MRS cluster is used. You can obtain the sample program from the MRS cluster client installation directory, that is, /opt/client/Flink/flink/examples/batch/WordCount.jar.

    Upload WordCount.jar to the mrs-demo-data/program directory.

Step 3: Creating and Running a Flink Job

Method 1: Submit a job online on the console.

  1. Log in to the MRS management console and click the cluster name to go to the cluster details page.
  2. On the Dashboard tab page, click Synchronize next to IAM User Sync to synchronize IAM users.
  3. Click the Jobs tab.
  4. Click Create. In the Create Job dialog box that is displayed, set the following parameters to create a Flink job.

    • Type: Select Flink.
    • Name: Customize a job name, for example, flink_obs_test.
    • Program Path: In this example, the WordCount program of the Flink client is used.
    • Program Parameter: Use the default value.
    • Parameters: Enter the input and output parameters of the application. The input parameter indicates the test data to be analyzed, and the output parameter indicates the result output file.

      In this example, set this parameter to --input obs://mrs-demo-data/flink/mrs_flink_test.txt --output obs://mrs-demo-data/flink/output.

    • Service Parameter: Use the default values. For details about how to manually configure job parameters, see Running a Flink Job.

  5. Confirm the job configuration information and click OK.

Method 2: Submit a job using the cluster client.

  1. Log in to the node where the cluster client is installed as user root and go to the client installation directory.

    su - omm

    cd /opt/client

    source bigdata_env

  2. Run the following command to check whether the cluster can access OBS:

    hdfs dfs -ls obs://mrs-demo-data/flink

  3. Submit a Flink job and specify the source file data for consumption.

    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_0011
    Job has been submitted with JobID a89b561de5d0298cb2ba01fbc30338bc
    Program execution finished
    Job with JobID a89b561de5d0298cb2ba01fbc30338bc has finished.
    Job Runtime: 1200 ms

Step 4: Viewing Job Execution Results

  1. After the job is submitted, log in to FusionInsight Manager of the MRS cluster and choose Cluster > Services > Yarn.
  2. Click the link next to ResourceManager WebUI to access the native Yarn web UI. On the All Applications page that is displayed, choose Applications on the left, and view the job running status and run logs.

  3. After the job execution is complete, you can view the data analysis result in the specified result output file in the OBS file system.

    Download the output file to your local PC and open the file to view the analysis result.

    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

    If you do not specify the output directory when submitting a job using the cluster client CLI, you can view the data analysis result on the job running page.

    Job with JobID xxx has finished.
    Job Runtime: xxx ms
    Accumulator 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)

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback