1.Flink 1.12.1本地模式安装

步骤 1:下载

操作系统需求建议使用Linux系统例如Centos或Ubuntu系统,这里我使用的ubuntu20.04

为了运行Flink,只需提前安装好 Java 8 或者 Java 11。你可以通过以下命令来检查 Java 是否已经安装正确。

clipboard(2).png

java -version

打开Flink官网

https://flink.apache.org

或https://mirrors.bfsu.edu.cn/apache/flink/flink-1.12.2/flink-1.12.2-bin-scala_2.11.tgz

点击 Downloads (1.12.2 为Flink版本,2.11为scala版本)


clipboard(3).png

也可以将页面拉到底部下载历史版本

下载 最新版 release 1.12.2 并解压。

tar -xzf flink-1.12.2-bin-scala_2.11.tgz

sudo mv flink-1.12.2 /opt cd /opt/flink-1.12.2

步骤 2:启动集群

修改配置文件,开启历史服务器

vi /opt/flink-1.12.2/conf/flink-conf.yaml

\#在尾部加入

jobmanager.archive.fs.dir: file:///home/jack/tmp/

historyserver.web.address: 0.0.0.0

historyserver.web.port: 8082

historyserver.archive.fs.dir: file:///home/jack/tmp/

historyserver.archive.fs.refresh-interval: 10000

Flink 附带了一个 bash 脚本,可以用于启动本地集群和历史服务器。

./bin/start-cluster.sh Starting cluster. Starting standalonesession daemon on host. Starting taskexecutor daemon on host.

./bin/historyserver.sh start

Starting historyserver daemon on host.

检查是否成功启动

jps

24593 HistoryServer  #历史服务器

24246 TaskManagerRunner #任务执行器

23965 StandaloneSessionClusterEntrypoint #独立集群

25102 Jps

注:历史服务器开启后可表里执行记录

步骤 3:提交作业(Job)

Flink 的 Releases 附带了许多的示例作业。你可以任意选择一个,快速部署到已运行的集群上。

./bin/flink run examples/streaming/WordCount.jar tail log/flink-*****-taskexecutor-*****.out (nymph,1)

(in,3)

(thy,1)

(orisons,1)

(be,4)

(all,2)

(my,1)

(sins,1)

(remember,1)

(d,4)

另外,你可以通过 Flink 的 Web UI 来监视集群的状态和正在运行的作业。

默认WebUI地址:http://localhost:8081/

clipboard(1).png

默认的历史服务器地址:http://localhost:8082/

历史服务器与WebUI相同,但是没有提交任务的菜单

clipboard.png

步骤 4:停止集群

完成后,你可以快速停止集群和所有正在运行的组件。

$ ./bin/stop-cluster.sh

步骤5:配置环境变量(可选)

配置环境变量

vi /etc/profile

export FLNK_HOME=/opt/flink-1.12.2/

export PATH=$FLINK_HOME/bin:$PATH

配置开启启动

vi /etc/rc.local

chmod +x rc.local

export FLNK_HOME=/opt/flink-1.12.2/

export PATH=$FLINK_HOME/bin:$PATH

/opt/flink-1.12.1/bin/start-cluster.sh

/opt/flink-1.12.1/bin/historyserver.sh start

你可能感兴趣的:(1.Flink 1.12.1本地模式安装)