flink-example分析 batch/WordCount.jar 和streaming/SocketWindowWordCount.jar
java版本环境
openjdk version "1.8.0_282" OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~20.10-b08) OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)
flink版本环境
Apache Flink 1.12.2 for Scala 2.12 (asc, sha512)
运行一个示例
1.启动flink集群
$ ./bin/start-cluster.sh
2.运行WordCount实例,默认使用内置数据
$ ./bin/flink run ./examples/batch/WordCount.jar
运行WordCount使用真实数据
$ ./bin/flink run ./examples/batch/WordCount.jar --input /path/to/some/text/data --output /path/to/result
image-20210318150209310.png3.运行socketwindowWordCount实例
模拟数据流入口
$nc -l 9000
$ ./bin/flink run ./examples/streaming/SocketWindowWordCount.jar --port 9000
image-20210318151544981.png
网友评论