Flink安装与部署
Flink下载
https://flink.apache.org/downloads.html
选择与安装的scala兼容的版本,安装的Scala版本是2.11,选择Flink1.9.2即可:https://archive.apache.org/dist/flink/flink-1.9.2/flink-1.9.2-bin-scala_2.11.tgz
安装部署 Flink
# 解压缩
tar -zxvf ./flink-1.9.2-bin-scala_2.11.tgz
# 添加环境变量
echo '# Apache Flink' >> /etc/profile
echo 'export FLNK_HOME=/root/develop/flink/apache-flink-1.9.2' >> /etc/profile
echo 'export PATH=$FLINK_HOME/bin:$PATH' >> /etc/profile
# 使环境变量生效
source /etc/profile
启动Flink
[root@localhost flink-1.9.2]# ./bin/start-cluster.sh
Starting cluster.
Starting standalonesession daemon on host localhost.localdomain.
Starting taskexecutor daemon on host localhost.localdomain.
此时可以通过观察logs目录下的日志来检测系统是否正在运行:tail log/flink--standalonesession-.log

JobManager同时会在8081端口上启动一个web管理界面,访问地址:http://localhost:8081,这里要切换为你实际的IP地址

目录结构
[root@localhost flink-1.9.2]# ll
total 816
drwxr-xr-x. 2 502 games 4096 Jul 6 08:16 bin
drwxr-xr-x. 2 502 games 4096 Jul 6 08:16 conf
drwxr-xr-x. 7 502 games 76 Jul 6 08:16 examples
drwxr-xr-x. 2 502 games 169 Jul 6 08:16 lib
-rw-r--r--. 1 502 games 11357 Dec 2 2019 LICENSE
drwxr-xr-x. 2 502 games 4096 Jul 6 08:16 licenses
drwxr-xr-x. 2 502 games 252 Jul 6 08:17 log
-rw-r--r--. 1 502 games 799111 Jan 24 2020 NOTICE
drwxr-xr-x. 3 502 games 4096 Jul 6 08:16 opt
drwxr-xr-x. 2 502 games 24 Jul 6 08:16 plugins
-rw-r--r--. 1 502 games 1308 Dec 2 2019 README.txt
示例程序
在%FLINK_HOME%目录下执行示例程序:
./bin/flink run ./examples/batch/WordCount.jar
控制台会打印出计算的结果:

<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.11</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.11</artifactId>
<version>1.9.2</version>
</dependency>
</dependencies>

浙公网安备 33010602011771号