0


通过 docker-compose 部署 Flink

概要

通过 docker-compose 以

Session Mode

部署 flink

前置依赖

  • Docker、docker-compose
  • flink 客户端
  • docker-compose.yml
version:"2.2"services:jobmanager:image: flink:1.17.2
    ports:-"8081:8081"command: jobmanager
    volumes:- ${PWD}/checkpoint:/opt/flink/checkpoint
      - ${PWD}/savepoint:/opt/flink/savepoint
    environment:-|
        FLINK_PROPERTIES=
        jobmanager.rpc.address: jobmanagertaskmanager:image: flink:1.17.2
    depends_on:- jobmanager
    command: taskmanager
    scale:1volumes:- ${PWD}/checkpoint:/opt/flink/checkpoint
      - ${PWD}/savepoint:/opt/flink/savepoint
    environment:-|
        FLINK_PROPERTIES=
        jobmanager.rpc.address: jobmanager
        taskmanager.numberOfTaskSlots: 3

部署

# 下载 docker、docker-compose# docker-compose 部署# 复制上述 docker-compose.yml 内容
$ vim docker-compose.yml

# 创建 savepoint、checkpoint 目录用于保存状态数据
$ mkdir savepoint checkpoint

$ docker-compose up -d

提交任务

# 下载 flink 客户端
$ wget https://archive.apache.org/dist/flink/flink-1.17.0/flink-1.17.0-bin-scala_2.12.tgz
$ tar xvf flink-1.17.0-bin-scala_2.12.tgz
$ cd flink-1.17.0-bin-scala_2.12

# 提交任务
$ bin/flink run -d-m192.168.56.103:8081 -c com.xchenhao.Demo flink-cdc-1.0-SNAPSHOT-jar-with-dependencies.jar

# 查看任务列表
$ bin/flink list -m192.168.56.103:8081
Waiting for response...
------------------ Running/Restarting Jobs -------------------
02.02.2024 16:45:01 : 9f70a7c1430d609eaa3434c4f30d1e93 : Flink-CDC (RUNNING)
--------------------------------------------------------------
No scheduled jobs

Web UI 查看

浏览器访问目标端口 192.168.56.103:8081
webui

其它常用命令

  • 从指定 checkpoint 恢复任务
bin/flink run -d-m192.168.56.103:8081 -s file:///opt/flink/checkpoint/47bea16a8ffcb51beff21ed1c7297dc1/chk-129773 -c com.xchenhao.Demo flink-cdc-1.0-SNAPSHOT-jar-with-dependencies.jar
  • 从指定 savepoint 恢复任务
bin/flink run -d-m192.168.56.103:8081 -s file:///opt/flink/savepoint/savepoint-63712d-d7cbfee1ede9  -c com.xchenhao.Demo flink-cdc-1.0-SNAPSHOT-jar-with-dependencies.jar
  • 保存 savepoint
bin/flink savepoint 9f70a7c1430d609eaa3434c4f30d1e93 file:///opt/flink/savepoint -m192.168.56.103:8081
  • 取消任务
bin/flink cancel 9f70a7c1430d609eaa3434c4f30d1e93 -m192.168.56.103:8081
  • 停止任务并保存 savepoint
bin/flink stop 9f70a7c1430d609eaa3434c4f30d1e93 -p file:///opt/flink/savepoint -m192.168.56.103:8081

参考

标签: docker flink 容器

本文转载自: https://blog.csdn.net/xchenhao/article/details/136053998
版权归原作者 陈挨踢 所有, 如有侵权,请联系我们删除。

“通过 docker-compose 部署 Flink”的评论:

还没有评论