Flink部署及作业提交

Flink部署及作业提交

Flink源码编译

Setup: Download and Start Flink

Flink runs on Linux, Mac OS X, and Windows. To be able to run Flink, the only requirement is to have a working Java 8.x installation. Windows users, please take a look at the Flink on Windows guide which describes how to run Flink on Windows for local setups.

You can check the correct installation of Java by issuing the following command:

java -version

If you have Java 8, the output will look something like this:

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
  1. Download a binary from the downloads page. You can pick any Hadoop/Scala combination you like. If you plan to just use the local file system, any Hadoop version will work fine.
  2. Go to the download directory.
  3. Unpack the downloaded archive.
$ cd ~/Downloads        # Go to download directory
$ tar xzf flink-*.tgz   # Unpack the downloaded archive
$ cd flink-1.7.2

通过下载Flink源码进行编译,不是使用直接下载二进制包
下载到:
1)服务器:~/source wget https://github.com/apache/flink/archive/release-1.7.0.tar.gz
2) 本地:https://github.com/apache/flink/archive/release-1.7.0.tar.gz

mvn clean install -DskipTests -Pvendor-repos -Dfast -Dhadoop.version=2.6.0-cdh5.15.1

第一次编译是需要花费很长时间的,因为需要去中央仓库下载flink源码中所有的依赖包

Standalone单机模式

Standalone的最简单的方式

./bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000
./bin/flink # 路径  $FLINK_HOME

Start a Local Flink Cluster

$ ./bin/start-cluster.sh  # Start Flink

Check the Dispatcher’s web frontend at http://localhost:8081 and make sure everything is up and running. The web frontend should report a single available TaskManager instance.

在这里插入图片描述

You can also verify that the system is running by checking the log files in the logs directory:

$ tail log/flink-*-standalonesession-*.log
INFO ... - Rest endpoint listening at localhost:8081
INFO ... - http://localhost:8081 was granted leadership ...
INFO ... - Web frontend listening at http://localhost:8081.
INFO ... - Starting RPC endpoint for StandaloneResourceManager at akka://flink/user/resourcemanager .
INFO ... - Starting RPC endpoint for StandaloneDispatcher at akka://flink/user/dispatcher .
INFO ... - ResourceManager akka.tcp://flink@localhost:6123/user/resourcemanager was granted leadership ...
INFO ... - Starting the SlotManager.
INFO ... - Dispatcher akka.tcp://flink@localhost:6123/user/dispatcher was granted leadership ...
INFO ... - Recovering all persisted jobs.
INFO ... - Registering TaskManager ... under ... at the SlotManager.

Read the Code

You can find the complete source code for this SocketWindowWordCount example in scala and java on GitHub.

public class SocketWindowWordCount {
   

    public static void main(String[] args) throws Exception {
   

        // the port to connect to
        final int port;
        try {
   
            final ParameterTool params = ParameterTool.fromArgs(args);
            port = params.getInt("port");
        } catch (Exception e) {
   
            System.err.println("No port specified. Please run 'SocketWindowWordCount --port <port>'");
            return;
        }

        // get the execution environment
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        // get input data by connecting to the socket
        DataStream<String> text = env.socketTextStream("localhost", port, "\n");

        // parse the data, group it, window it, and aggregate the counts
        DataS
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flink是一个开源的流处理和批处理框架,支持分布式部署。下面是Flink分布式部署的一般步骤: 1. 确保你有一个Flink集群:Flink需要在一个或多个计算机上运行,形成一个集群。你可以在每台计算机上安装Flink,也可以使用现有的集群管理器(如Apache Mesos、Hadoop YARN或Kubernetes)来管理Flink集群。 2. 配置Flink集群:在每台计算机上,你需要配置Flink集群的相关参数。主要的配置文件是`flink-conf.yaml`,其中包含了一些关键的配置项,如任务管理器的数量、内存分配等。你可以根据需要进行相应的配置。 3. 启动Flink集群:在每台计算机上启动Flink集群的组件,包括任务管理器(TaskManager)和作业管理器(JobManager)。作业管理器负责接收作业提交请求,并将作业分发给任务管理器执行。 4. 提交作业:使用Flink提供的客户端工具或API,将你的Flink作业提交Flink集群中执行。你可以通过命令行工具`flink run`或使用Flink的REST API来提交作业。 5. 监控和管理:一旦作业提交成功,你可以使用Flink的Web界面或命令行工具来监控作业的执行情况。你可以查看作业的状态、任务的指标和日志等信息,也可以进行作业的管理操作,如取消、重新启动等。 以上是Flink分布式部署的一般步骤,具体的操作细节可能会有所不同,取决于你选择的集群管理器和部署环境。你可以参考Flink官方文档中的相关章节,了解更多详细信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值