Preface and some preparations
The first thing to be clear is that savepoint and checkpoint are not the same type.
Therefore, when doing savepoint experiments, there is no need to add checkpoint enable options in the code.
Add in $FLINK_HOME/conf/flink-conf.yaml
state.savepoints.dir: hdfs://Desktop:9000/flink-savepoints
The experiment code adopts [2]
------------------------------------------------------------------------------------------------------------------------
Experimental steps
First of all, note that this experiment is carried out in a standalone real cluster, not a local single-section pseudo-distributed cluster.
step | Step content |
① | Start Zookeeper, Hadoop, Flink (HA) three clusters (do not start the wrong order) |
②
|
mvn package cd target get: Job has been submitted with JobID a5c47eb5cd62ef61f0e0ae66f17aab58 |
③ | flink savepoint a5c47eb5cd62ef61f0e0ae66f17aab58 Savepoint completed. Path: hdfs://Desktop:9000/flink-savepoints/savepoint-a5c47e-bd57d19f884c |
④ | flink cancel a5c47eb5cd62ef61f0e0ae66f17aab58
Cancelling job a5c47eb5cd62ef61f0e0ae66f17aab58. WEB UI display |
⑤ | flink run -s hdfs://Desktop:9000/flink-savepoints/savepoint-a5c47e-bd57d19f884c -c WordCount -d /home/appleyuchi/桌面/Flink_Code/flink_state/savepoint/target/bbb-1.0-SNAPSHOT.jar
Job has been submitted with JobID 00b79db0e9123ebda8dcbb22a8d1e484
After restoring through the above command, you will see that the restore information is updated in the web ui
At the same time, the results from the previous Task Managers still exist
We continue to input heiheihei in nc -lk 9999, can we continue to output in the same taskmanager mentioned above? The answer is no, The program after restore ran to another taskmanager when outputting the results, so this is a bit imperfect |
The above process mainly refers to [1]
Reference
[2] Intellij runs the wordcount experiment of flink-Java version