一、搭建 maven 工程 FlinkDemo
pom 文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.youy</groupId>
<artifactId>flink-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.12</artifactId>
<version>1.10.1</version>
</dependency>
</dependencies>
</project>
二、流处理 FlinkDemo
package org.youy;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
public class FlinkDemo {
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<Integer> integerDataStream = env.fromElements(1, 2, 4, 555, 3, 34, 56, 756);
integerDataStream.print();
env.execute();
}
}
三、Flink 部署(Standalone 模式)
1.安装启动
修改 flink/conf/flink-conf.yaml 文件:
修改 /conf/masters 文件:
node01:8081
修改配置文件/conf/slaves
node02
node03
分发给另外两台机子:
启动:
2.访问 http://node01:8081 可以对 flink 集群和任务进行监控管理。
查看结果: