Flink官方架构图:
Flink集群架构主要看 运行时 的集群架构,运行时的集群架构主要由 两种 类型的 进程 构成:
这两种进程(JM和TM)根据不同的部署模式,启动方式不同。
一键启停整个Flink集群(包括JM和NM)
bin/start-cluster.sh
bin/stop-cluster.sh
单独启动JobManager(或向现有集群添加JobManager)
bin/jobmanager.sh ((start|start-foreground) [args] [webui-port])|stop|stop-all
单独启动TaskManager(或向现有集群添加TaskManager)
bin/taskmanager.sh start|start-foreground|stop|stop-all
准备好k8s环境及flink docker镜像
Session mode
1.启动 Kubernetes session
$ ./bin/kubernetes-session.sh -Dkubernetes.cluster-id=my-first-flink-cluster
2.提交Job
$ ./bin/flink run
--target kubernetes-session
-Dkubernetes.cluster-id=my-first-flink-cluster
./examples/streaming/TopSpeedWindowing.jar
3.删除集群
$ kubectl delete deployment/my-first-flink-cluster
Application Mode
application mode需要将待执行的job代码打在flink镜像中:
1.基于Flink镜像制作镜像
FROM flink
RUN mkdir -p $FLINK_HOME/usrlib
COPY /path/of/my-flink-job.jar $FLINK_HOME/usrlib/my-flink-job.jar
2.启动application mode
$ ./bin/flink run-application
--target kubernetes-application
-Dkubernetes.cluster-id=my-first-application-cluster
-Dkubernetes.container.image=custom-image-name
local:///opt/flink/usrlib/my-flink-job.jar
Per-job Mode
已过时,1.6中已废弃
Session Mode
on yarn上的session mode有两种操作:
./bin/flink run -t yarn-session
-Dyarn.application.id=application_XXXX_YY
./examples/streaming/TopSpeedWindowing.jar
# (0) export HADOOP_CLASSPATH
export HADOOP_CLASSPATH=`hadoop classpath`
# (1) Start YARN Session
./bin/yarn-session.sh --detached
# (2) You can now access the Flink Web Interface through the
# URL printed in the last lines of the command output, or through
# the YARN ResourceManager web UI.
# (3) Submit example job
./bin/flink run ./examples/streaming/TopSpeedWindowing.jar
# (4) Stop YARN session (replace the application id based
# on the output of the yarn-session.sh command)
echo "stop" | ./bin/yarn-session.sh -id application_XXXXX_XXX
Application Mode
./bin/flink run-application -t yarn-application ./examples/streaming/TopSpeedWindowing.jar
启动后查看
# List running job on the cluster
./bin/flink list -t yarn-application -Dyarn.application.id=application_XXXX_YY
# Cancel running job
./bin/flink cancel -t yarn-application -Dyarn.application.id=application_XXXX_YY
页面更新:2024-04-01
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号