Connect to Flink via CLI

Flink provides a command-line interface to run programs packaged as Java archives (jar) and to control their execution. To submit a new job means to upload the job’s jar file and related dependencies to a running Flink cluster and to execute it.

Flink releases come with example jobs available in the /usr/lib/flink/examples/ directory. To deploy the example word count job to the running cluster, execute the following command:

$ flink run /usr/lib/flink/examples/streaming/WordCount.jar

The other examples can be started in a similar way. Many examples run without passing any arguments to them, and simply using build-in data. To run WordCount.jar with real data, you have to pass the path to the input data:

$ ./bin/flink run ./examples/batch/WordCount.jar --input /path/to/some/text/data --output /path/to/result
NOTE
Non-local file systems require a schema prefix, such as hdfs://.

You can verify the output by viewing the logs:

$ tail log/flink-*-taskexecutor-*.out

Sample output:

(nymph,1)
(in,3)
(thy,1)
(orisons,1)
(be,4)
(all,2)
(my,1)
(sins,1)
(remember,1)
(d,4)
Found a mistake? Seleсt text and press Ctrl+Enter to report it