Flink Kubernates Native - 入门

创建 namespace

[root@CentOSA flink-1.17.1]# kubectl create ns flink-native
[root@CentOSA flink-1.17.1]# kubectl config set-context --current --namespace=flink-native

命令空间添加资源限制

[root@CentOSA flink-1.17.1]# vim namespace-ResourceQuota.yaml
apiVersion: v1 
kind: ResourceQuota
metadata:name: mem-cpu-quotanamespace: flink-native
spec:hard:requests.cpu: "10"requests.memory: 10Gilimits.cpu: "10"limits.memory: 10Gi
[root@CentOSA flink-1.17.1]# kubectl apply -f namespace-ResourceQuota.yaml

创建用户并赋权

[root@CentOSA flink-1.17.1]# kubectl create serviceaccount ric
[root@CentOSA flink-1.17.1]# kubectl create clusterrolebinding flink-role-binding-flink --clusterrole=edit --serviceaccount=flink-native:ric --namespace=flink-native
  • 提前在所有的flnk节点拉取flink镜像
[root@CentOSA flink-1.17.1]# docker pull apache/flink:1.17.1-scala_2.12 
[root@CentOSA flink-1.17.1]# docker pull flink:1.17.1-scala_2.12 

SessionMode

创建Flink 会话

./bin/kubernetes-session.sh \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.cluster-id=session001 \-Dtaskmanager.memory.process.size=1024m \-Dkubernetes.taskmanager.cpu=1 \-Dtaskmanager.numberOfTaskSlots=4 \-Dresourcemanager.taskmanager-timeout=3600000 \-Dkubernetes.rest-service.exposed.type=NodePort \-Dkubernetes.container.image.ref=flink:1.17.1-scala_2.12 
2023-08-28 15:50:06,802 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: taskmanager.memory.process.size, 1728m
2023-08-28 15:50:06,805 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: jobmanager.bind-host, localhost
2023-08-28 15:50:06,805 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: taskmanager.bind-host, localhost
2023-08-28 15:50:06,805 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: taskmanager.host, localhost
2023-08-28 15:50:06,805 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: parallelism.default, 1
2023-08-28 15:50:06,805 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: jobmanager.execution.failover-strategy, region
2023-08-28 15:50:06,805 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: jobmanager.rpc.address, localhost
2023-08-28 15:50:06,806 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: taskmanager.numberOfTaskSlots, 1
2023-08-28 15:50:06,806 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: rest.address, localhost
2023-08-28 15:50:06,806 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: jobmanager.memory.process.size, 1600m
2023-08-28 15:50:06,806 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: jobmanager.rpc.port, 6123
2023-08-28 15:50:06,806 INFO  org.apache.flink.configuration.GlobalConfiguration           [] - Loading configuration property: rest.bind-address, localhost
2023-08-28 15:50:06,900 INFO  org.apache.flink.client.deployment.DefaultClusterClientServiceLoader [] - Could not load factory due to missing dependencies.
2023-08-28 15:50:08,271 INFO  org.apache.flink.runtime.util.config.memory.ProcessMemoryUtils [] - The derived from fraction jvm overhead memory (160.000mb (167772162 bytes)) is less than its min value 192.000mb (201326592 bytes), min value will be used instead
2023-08-28 15:50:08,291 INFO  org.apache.flink.runtime.util.config.memory.ProcessMemoryUtils [] - The derived from fraction jvm overhead memory (102.400mb (107374184 bytes)) is less than its min value 192.000mb (201326592 bytes), min value will be used instead
2023-08-28 15:50:08,292 INFO  org.apache.flink.runtime.util.config.memory.ProcessMemoryUtils [] - The derived from fraction network memory (57.600mb (60397978 bytes)) is less than its min value 64.000mb (67108864 bytes), min value will be used instead
2023-08-28 15:50:08,498 INFO  org.apache.flink.kubernetes.utils.KubernetesUtils            [] - Kubernetes deployment requires a fixed port. Configuration blob.server.port will be set to 6124
2023-08-28 15:50:08,498 INFO  org.apache.flink.kubernetes.utils.KubernetesUtils            [] - Kubernetes deployment requires a fixed port. Configuration taskmanager.rpc.port will be set to 6122
2023-08-28 15:50:09,989 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Create flink session cluster session001 successfully, JobManager Web Interface: http://192.168.42.130:32432

可以根据提示信息访问JobManager Web Interface: http://192.168.42.130:32432页面
Session会话页面

提交任务到指定会话

运行flink session任务

 ./bin/flink run \--target kubernetes-session \-Dkubernetes.cluster-id=session001 \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.rest-service.exposed.type=NodePort \./examples/streaming/TopSpeedWindowing.jar
Use --input to specify file input.
Printing result to stdout. Use --output to specify output path.
2023-08-28 15:54:02,974 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Retrieve flink cluster session001 successfully, JobManager Web Interface: http://192.168.42.130:32432
Job has been submitted with JobID 465dd11e73b5c9ac49c8e2945bf862b2

提交任务结果

查看任务列表

 ./bin/flink list \--target kubernetes-session \-Dkubernetes.cluster-id=session001 \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.rest-service.exposed.type=NodePort \
2023-08-28 15:57:33,654 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Retrieve flink cluster session001 successfully, JobManager Web Interface: http://192.168.42.130:32432
Waiting for response...
------------------ Running/Restarting Jobs -------------------
28.08.2023 15:54:03 : 465dd11e73b5c9ac49c8e2945bf862b2 : CarTopSpeedWindowingExample (RUNNING)
--------------------------------------------------------------
No scheduled jobs.

取消任务:

 ./bin/flink cancel \--target kubernetes-session \-Dkubernetes.cluster-id=session002 \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.rest-service.exposed.type=NodePort \465dd11e73b5c9ac49c8e2945bf862b2
Cancelling job 465dd11e73b5c9ac49c8e2945bf862b2.
2023-08-28 16:02:43,209 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Retrieve flink cluster session001 successfully, JobManager Web Interface: http://192.168.42.130:32432
Cancelled job 465dd11e73b5c9ac49c8e2945bf862b2.

删除session作业:

[root@CentOSA flink-1.17.1]# kubectl delete deployment session001 -n flink-native
deployment.apps "session001" deleted

Application Model

构建docker镜像

1、编写DockerFile

[root@CentOSA flink-1.17.1] cd /export/server/app-mode
[root@CentOSA app-mode] vi Dockerfile
FROM flink
RUN mkdir -p $FLINK_HOME/usrlib
COPY TopSpeedWindowing.jar $FLINK_HOME/usrlib/TopSpeedWindowing.jar

2、构建镜像文件

[root@CentOSC app-mode]# docker build -t my-flink-job:1.0 ./
[+] Building 0.6s (8/8) FINISHED                                                                                                                                                                                      docker:default=> [internal] load .dockerignore                                                                                                                                                                                               0.1s=> => transferring context: 2B                                                                                                                                                                                                 0.0s=> [internal] load build definition from Dockerfile                                                                                                                                                                            0.1s=> => transferring dockerfile: 271B                                                                                                                                                                                            0.0s=> [internal] load metadata for docker.io/library/flink:1.17.1-scala_2.12                                                                                                                                                      0.0s=> [1/3] FROM docker.io/library/flink:1.17.1-scala_2.12                                                                                                                                                                        0.1s=> [internal] load build context                                                                                                                                                                                               0.0s=> => transferring context: 17.04kB                                                                                                                                                                                            0.0s=> [2/3] RUN mkdir -p /opt/flink/usrlib                                                                                                                                                                                        0.3s=> [3/3] COPY TopSpeedWindowing.jar  /opt/flink/usrlib/TopSpeedWindowing.jar                                                                                                                                                   0.0s=> exporting to image                                                                                                                                                                                                          0.0s=> => exporting layers                                                                                                                                                                                                         0.0s=> => writing image sha256:a017db16aaa8086045dc1b28315e6e2fe47113aa41e1a0f547b58c1b191dac4a                                                                                                                                    0.0s=> => naming to docker.io/library/my-flink-job:1.0                                                                                                                                                                             0.0s
[root@CentOSC appMode]# docker images
REPOSITORY                                           TAG                 IMAGE ID       CREATED              SIZE
my-flink-job                                         1.0                 a017db16aaa8   About a minute ago   782MB
flannel/flannel                                      v0.22.2             d73868a08083   10 days ago          70.2MB
flink                                                1.17.1-scala_2.12   efd18635797b   11 days ago          782MB
flannel/flannel-cni-plugin                           v1.2.0              a55d1bad692b   5 weeks ago          8.04MB
apache/flink                                         1.17.1-scala_2.12   fef5f770f8b3   3 months ago         780MB
registry.aliyuncs.com/google_containers/kube-proxy   v1.20.5             5384b1650507   2 years ago          118MB
registry.aliyuncs.com/google_containers/pause        3.2                 80d28bedfe5d   3 years ago          683kB

启动任务

 ./bin/flink run-application \--target kubernetes-application \-Dkubernetes.cluster-id=my-first-application-cluster \-Dkubernetes.container.image=my-flink-job:1.0 \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.rest-service.exposed.type=NodePort \
2023-08-28 16:07:45,180 INFO  org.apache.flink.kubernetes.utils.KubernetesUtils            [] - Kubernetes deployment requires a fixed port. Configuration blob.server.port will be set to 6124
2023-08-28 16:07:45,181 INFO  org.apache.flink.kubernetes.utils.KubernetesUtils            [] - Kubernetes deployment requires a fixed port. Configuration taskmanager.rpc.port will be set to 6122
2023-08-28 16:07:46,742 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Create flink application cluster my-first-application-cluster successfully, JobManager Web Interface: http://192.168.42.130:32003

App 应用模型

查看任务列表

./bin/flink list \--target kubernetes-application \-Dkubernetes.cluster-id=my-first-application-cluster \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.rest-service.exposed.type=NodePort 
2023-08-28 16:10:00,093 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Retrieve flink cluster my-first-application-cluster successfully, JobManager Web Interface: http://192.168.42.130:32003
Waiting for response...
------------------ Running/Restarting Jobs -------------------
28.08.2023 16:07:59 : c9ec57a2003a808ef5df04219fc7aacb : CarTopSpeedWindowingExample (RUNNING)
--------------------------------------------------------------
No scheduled jobs.

删除任务

 ./bin/flink cancel \--target kubernetes-application \-Dkubernetes.cluster-id=my-first-application-cluster \-Dkubernetes.namespace=flink-native \-Dkubernetes.jobmanager.service-account=ric \-Dkubernetes.rest-service.exposed.type=NodePort \c9ec57a2003a808ef5df04219fc7aacb
2023-08-28 16:11:16,963 INFO  org.apache.flink.kubernetes.KubernetesClusterDescriptor      [] - Retrieve flink cluster my-first-application-cluster successfully, JobManager Web Interface: http://192.168.42.130:32003
Cancelled job c9ec57a2003a808ef5df04219fc7aacb.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/87514.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

大数据Flink(六十九):SQL 数据类型

文章目录 SQL 数据类型 一、原子数据类型 二、​​​​​​复合数据类型 SQL 数据类型 在介绍完一些基本概念之后,我们来认识一下

LAMP介绍与配置

一.LAMP 1.1.LAMP架构的组成 CGI(通用网关接口)和FastCGI(快速公共网关接口)都是用于将Web服务器与后端应用程序(如PHP、Python等)进行交互的协议/接口。 特点 CGI FastCGI 运行方式 每个请求启动…

Excel显示此值与此单元格定义的数据验证限制不匹配怎么办?

总结:1、在编辑excel文档的时候,弹出此时预测单元格定义的数据验证,限制不匹配的提示。2、这是我们点击菜单来的数据菜单。3、然后点击数据工具栏的数据验证下拉按钮。4、在弹出的菜单中选择数据验证的菜单项。5、然后在打开的窗口中点击左下…

Windows-docker集成SRS服务器的部署和使用

Windows-docker集成SRS服务器的部署和使用 一、Windows Docker安装 Docker Desktop 官方下载地址: https://docs.docker.com/desktop/install/windows-install/ 下载windows版本的就可以了。 注意:此方法仅适用于 Windows 10 操作系统专业版、企业版、…

HTTP 协议

目录 ​编辑一、HTTP 协议是什么 二、抓包工具的使用 三、HTTP 请求 1、认识 URL 2、认识方法 3、认识请求 “报头” HOST : Content-Length 和 Content-Type​编辑 User-Agent Referer Cookie 四、HTTP 响应 1、认识状态码 2、通过 form 表单构造 H…

mysql的登录与退出

mysql是c/s架构,意味着同时要有客户端和服务端 1 找到客户端。mysql.exe的安装目录 打开命令行 2 输入对应的服务器的ip,如果是本地,就是Localhost,如果是远程服务器,那就输入对应ip/域名。并且指定mysql监听的端口 …

4. 池化层相关概念

4.1 池化层原理 ① 最大池化层有时也被称为下采样。 ② dilation为空洞卷积,如下图所示。 ③ Ceil_model为当超出区域时,只取最左上角的值。 ④ 池化使得数据由5 * 5 变为3 * 3,甚至1 * 1的,这样导致计算的参数会大大减小。例如1080P的电…

IT运维:使用数据分析平台监控DELL服务器

概述 在企业日常运维中,我们有着大量的服务器设备,设备故障一般可以通过常用的监控软件实现自动告警,但如果在管理运维中我们要做的不仅仅是发现故障,处理硬件故障,我们还需要进一步的了解,今年一共出现了多…

【高阶数据结构】map和set的介绍和使用 {关联式容器;键值对;map和set;multimap和multiset;OJ练习}

map和set的介绍和使用 一、关联式容器 关联式容器和序列式容器是C STL中的两种不同类型的容器。 关联式容器是基于键值对的容器,其中每个元素都有一个唯一的键值,可以通过键值来访问元素。关联式容器包括set、multiset、map和multimap。 序列式容器是…

C语言学习笔记(完整版)

文章目录 算法算法的基本概念算法的特征算法的优劣 描述算法三种基本结构流程图N-S流程图伪代码 常量和变量了解数据类型常量整形常量实型常量字符型常量转义字符符号常量 变量整形变量实型变量字符型变量 表达式与运算符赋值运算符和赋值表达式变量赋初值强制类型转换 算术运算…

NLNet、GCNet、RTNet三种多头注意力网络的对比与分析

目录 一、中心思想 二、网络结构的异同点 三、网络结构的改进 3.1 GCNet的改进 3.2 RTNet的改进 四、总结 一、中心思想 三种网络最终目的都是为了捕获远程依赖关系或是全局上下文信息以增强目标检测或是目标分割的效果。 NLNet:卷积运算只能一次处理一个局…

16- flask-bootstrap模板的使用

Flask 中支持 flask-bootstrap模板 和 bootstrap-flask模板 # 不使用: bootstrap-flask # pip install bootstrap-flask1.3.1 # 支持bootstrap 4 # pip install flask-bootstrap # 支持bootstrap3# 中文文档:https://flask-bootstrap-zh.readthedocs.io/zh/latest/ # 样式文档…