当前位置:   article > 正文

五、Flink入门--客户端操作_flink -m localhost

flink -m localhost

1.客户端操作总体概览

Flink提供了丰富的客户端操作来提交任务或与任务交互,我们从五个方面介绍Flink客户端的具体操作,分别是Flink命令行模式,scala-shell模式, sql-client 模式,restful模式,界面模式.
在这里插入图片描述

2. Flink命令行模式
2.1 stand-alone模式

首先启动stand-alone模式的集群

bin/start-cluster.sh
  • 1

提交一个example任务,-d 表示detached模式,即提交了后会退出shell,如果不加-d shell会一直在运行不退出。

bin/flink run -d examples/streaming/TopSpeedWindowing.jar
  • 1

查看当前集群所有的任务列表:

a.默认模式下-m表示jm的地址
bin/flink list -m localhost:8081

b.ha模式下用-z表示zk地址查看
bin/flink list -z localhost:2181

------------------ Running/Restarting Jobs -------------------
20.05.2019 16:04:11 : 5f1a16394dc207969a0cff904ca57726 : CarTopSpeedWindowingExample (RUNNING)
--------------------------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

停止任务,并设置savepoint 路径

bin/flink cancel -m locahost:8081 -s /tmp/savepoint 5f1a16394dc207969a0cff904ca57726

Cancelling job 5f1a16394dc207969a0cff904ca57726 with savepoint to /tmp/savepoint.
Cancelled job 5f1a16394dc207969a0cff904ca57726. Savepoint stored in file:/tmp/savepoint/savepoint-5f1a16-26cd0491e260.
  • 1
  • 2
  • 3
  • 4

查看savepoint:

ll /tmp/savepoint/

drwxrwxr-x 2 hadoopuser hadoopuser 4096 May 20 16:20 savepoint-5f1a16-26cd0491e260
  • 1
  • 2
  • 3

从savepoint恢复执行任务:

bin/flink run -d -s /tmp/savepoint/savepoint-5f1a16-26cd0491e260/ examples/streaming/TopSpeedWindowing.jar
Job has been submitted with JobID 9e9a1bab6256175706ffaa0e0f4f6535

可以在jm的日志中发现如下内容,证明任务是从checkpoint启动的
Starting job 9e9a1bab6256175706ffaa0e0f4f6535 from savepoint /tmp/savepoint/savepoint-5f1a16-26cd04
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/396768?site
推荐阅读
相关标签
  

闽ICP备14008679号