见上图:后续再整理
本处主要记录standalone和on yarn两种部署方式
conf 目录下调整文件
主要关注如下文件
通用配置
localhost:8081
8081位网页访问的端口号,localhost为主机名
localhost
localhost为taskmanager的地址,可以设置多个
启动命令
.bin/start-cluster.sh
启动后会出现如下信息
Starting cluster.
Starting standalonesession daemon on host MacBook.local.
Starting taskexecutor daemon on host MacBook.local.
其中 standalonesession daemon 为 Jobmanager;taskexecutor daemon 为task manager
启动完成后 执行 jps 命令
28330 StandaloneSessionClusterEntrypoint
28764 TaskManagerRunner
StandaloneSessionClusterEntrypoint 为jobmanager相关的提交job入口点
TaskManagerRunner为启动taskmanager的runner
启动完成后 进入 http://localhost:8081/#/overview 页面可以访问前端页面
停止命令
.bin/stop-cluster.sh
参考文档
提交作业分页面提交和命令提交
./bin/flink run -c com.ffl.study.flink.scala.stream.StreamWordCount -p 2 /Users/feifeiliu/Documents/work/java/study/study-flink/target/study-flink-1.0-SNAPSHOT.jar --host localhost --port 7777
-c 为运行的类入口;-p为并行度;然后紧跟 jar文件路径 和 参数
./bin/flink list # 查看运行任务
./bin/flink list -a # 查看所有任务
./bin/flink cancel f1f07f2b6f308633479d85141b1aef80
启动需要在lib目录下加入 flink-shaded-hadoop-2-uber-2.8.3-10.0.jar 包,2.8.3 为具体hadoop版本号,可以自己选择
On yarn模式又分Session-cluster和Per-Job-Cluster两种模式,一般采用后者
Session-cluster 在yarn中初始化一个flink集群,开辟指定的资源,以后提交任务都向这里提交。这个flink集群会常驻在yarn集群中,除非手动停止
启动命令
bin/yarn-session.sh -n 3 -s 3 -jm 1024 -tm 1024 -nm bjsxt -d
-n 为 taskManager数量,以后版本可以忽略,动态分配
-s 每个taskManager里slot数量
-jm,–jobManagerMemory :设置 JobManager 的内存,单位是 MB。
-tm,–taskManagerMemory :每个 TaskManager 的内存,单位是 MB。
-nm 在 YARN 上为一个自定义的应用设置一个名字
-d 后台执行
3. 提交作业
./bin/flink run -c com.ffl.study.flink.scala.stream.StreamWordCount -p 2 /Users/feifeiliu/Documents/work/java/study/study-flink/target/study-flink-1.0-SNAPSHOT.jar --host localhost --port 7777
yarn application --kill xxxx
每次提交都会创建一个新的flink集群,任务之间互相独立,互不影响,方便管理。任务执行完成后创建的集群也会消失
./bin/flink run -m yarn-cluster -c com.ffl.study.flink.scala.stream.StreamWordCount -p 2 /Users/feifeiliu/Documents/work/java/study/study-flink/target/study-flink-1.0-SNAPSHOT.jar --host localhost --port 7777
参考文档
控制一个应用程序执行的主进程,也就是说,每个应用程序都会被一个不同的JobManager所控制执行
Jobmanager会先接受到要执行的执行程序,这个执行程序包括:作业图(JobGraph)、逻辑流程图(logical dataflow graph)和打包了的所有类库和其它资源的jar包
JobManager会向资源管理器(ResourceManager)请求执行任务必要的资源,也就是任务管理器(TaskManger)上的插槽(slot)。一旦获取到足够资源,就会将执行图分发到真正运行它们的TaskManger上。而在运行过程中,JobManager会负责所有需要中央协调的操作,比如说检查点(checkpoint)的协调
分普通提交流程和on yarn模式
The Client is not part of the runtime and program execution, but is used to prepare and send a dataflow to the JobManager. After that, the client can disconnect (detached mode), or stay connected to receive progress reports (attached mode). The client runs either as part of the Java/Scala program that triggers the execution, or in the command line process ./bin/flink run …
The JobManager and TaskManagers can be started in various ways: directly on the machines as a standalone cluster, in containers, or managed by resource frameworks like YARN or Mesos. TaskManagers connect to JobManagers, announcing themselves as available, and are assigned work.
参考文档
思考
参考文档
参考文档
所有Flink程序都由三部分组成:Source、Transformation和Sink
数据传输形式
参考文档
https://ci.apache.org/projects/flink/flink-docs-release-1.11/zh/internals/job_scheduling.html
https://ci.apache.org/projects/flink/flink-docs-release-1.11/zh/learn-flink/datastream_api.html