一、在IDEA下导入打jar插件
### --- 将WordCountScalaStream打成jar包
~~~ 注意:集群搭建完毕后,Flink程序就可以打成Jar,
~~~ 在集群环境下类似于Step7中一样提交执行计算任务打jar包插件:
~~~ 该插件可以把包含所有的Flink程序需要的所有的依赖文件,包含scala依赖插件,
~~~ 可以不在环境下部署环境
<build>
<plugins>
<!-- 打jar插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
二、maven打成jar包并测试
### --- 在IDEA下打成jar包:WordCountScalaStream
~~~ ——>Maven——>FirstFlink:Lifeycle——>Clean——>
~~~ ——>package——>生成文件:original-FirstFlink-1.0-SNAPSHOT.jar——>END
### --- 在Flink-UI下导入jar包
~~~ ——>http://hadoop01:8081/——>Submit New Job——>Add New——>导入Jar:FirstFlink-1.0-SNAPSHOT.jar——>
~~~ ——>在Submit提交之前在:hadoop01:nc -lp 7777启动起来——>Submit——>END
将并行度设置为1;默认的
可以在Task Managers上查看到任务槽输出
设置并行度为2
三、在命令行下提交jar包:
### --- 集群模式下
~~~ 运行example测试
### --- 在UI上查看Running Jobs
~~~ 运行程序之前启动nc
[root@hadoop01 ~]# nc -lp 7777
~~~ # 启动运行程序
[root@hadoop01 ~]# cd /opt/yanqi/servers/flink-1.11.1/bin/
[root@hadoop01 bin]# ./flink run -c WordCountScalaStream -p 2 /root/myjars/FirstFlink-1.0-SNAPSHOT.jar
~~~ 输出参数
Job has been submitted with JobID 5431e42d51540000c36e0b0a16a2d3e8
~~~ # 取消应用程序
[root@hadoop01 bin]# ./flink cancel 5431e42d51540000c36e0b0a16a2d3e8
~~~ 输出参数
Cancelling job d6baff0e7472ac13f83f364ce47749ea.
Cancelled job d6baff0e7472ac13f83f364ce47749ea.