step1: 完成统计词频的flink代码,可以直接在我的github上下载:https://github.com/hiahia121/flink-wordscount
step2: 将代码打包成jar包,使用maven管理打包
涉及的打包插件
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <configuration> <createDependencyReducedPom>true</createDependencyReducedPom> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.flink.main.FlinkWordCountMain</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>reference.conf</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
完整的pom.xml
pom.xml
idea打包操作
运行打好的jar包,验证包可以使用
step3: 启动flink,参看如下链接
https://www.cnblogs.com/syw-home/p/13959696.html
step4: 将可执行的jar包上传到flink平台
step5: 在终端敲命令:nc -l 8823,监听8823端口作为server
step6: 提交运行job
step7:查看job运行情况
step8: 查看实时计算结果