当前位置: 首页 > article >正文

通过 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: jobmanager

  taskmanager:
    image: flink:1.17.2
    depends_on:
      - jobmanager
    command: taskmanager
    scale: 1
    volumes:
      - ${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 -m 192.168.56.103:8081 -c com.xchenhao.Demo flink-cdc-1.0-SNAPSHOT-jar-with-dependencies.jar

# 查看任务列表
$ bin/flink list -m 192.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 -m 192.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 -m 192.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 -m 192.168.56.103:8081
  • 取消任务
bin/flink cancel 9f70a7c1430d609eaa3434c4f30d1e93 -m 192.168.56.103:8081
  • 停止任务并保存 savepoint
bin/flink stop 9f70a7c1430d609eaa3434c4f30d1e93 -p file:///opt/flink/savepoint -m 192.168.56.103:8081

参考

  • https://blog.csdn.net/qq_41538097/article/details/129113866 docker 搭建 flink 并上传任务
  • https://nightlies.apache.org/flink/flink-docs-master/docs/deployment/resource-providers/standalone/docker/#flink-with-docker-compose Flink with Docker Compose
  • https://flink.apache.org/downloads/ Apache Flink® Downloads
  • https://blog.csdn.net/qq_26838315/article/details/125246223 Flink部署模式介绍(session,per-job,application)
  • https://nightlies.apache.org/flink/flink-docs-master/docs/deployment/resource-providers/standalone/docker/#session-mode-1 Session Mode

http://www.kler.cn/a/233559.html

相关文章:

  • Kafka参数了解
  • 前端知识点---Javascript的对象(Javascript)
  • 如何在Python中实现一个简单的搜索引擎:从零开始的指南
  • Java 堆内存管理详解:`-Xms` 和 `-Xmx` 参数的使用与默认内存设置
  • group_concat配置影响程序出bug
  • 腾讯云nginx SSL证书配置
  • 关节点检测
  • k8s filebeat 应用日志搜集
  • 各种能源折标准煤参考系数
  • 堆的数据结构以及堆的相应操作
  • 校园团餐SAAS系统源码
  • Spring Boot配置文件优先级
  • Java序列化详解
  • 深入了解RocketMQ消息中间件:架构、特性和应用场景
  • 过年在家玩幻兽帕鲁,腾讯云和阿里云Palworld新年礼物
  • 3.1-媒资管理之需求分析+搭建Nacos
  • 大模型学习笔记二:prompt工程
  • 力扣hot100 -- 双指针
  • BatchNorm介绍:卷积神经网络中的BN
  • 2024牛客寒假算法基础集训营1——H
  • 算法竞赛进阶指南——搜索
  • 鸿蒙学习-app.json5配置文件
  • EMNLP 2023精选:Text-to-SQL任务的前沿进展(下篇)——Findings论文解读
  • Blazor Wasm Gitee 码云登录
  • EMC学习笔记(二十三)降低EMI的PCB设计指南(三)
  • 四、机器学习基础概念介绍