本地安装

一 、下载

为了能够运行Flink,唯一的要求是有一个可以正常工作的的 Java8 或 Java11的环境。你可以通过以下命令来检查java 环境是否被正确的安装。

java -version

下载 1.12.0 版本并解压

tar -xzf flink-1.12.0-bin-scala_2.11.tgz
cd flink-1.12.0-bin-scala_2.11

二、启动一个 cluster

Flink自带了一个单独的脚本来启动一个本地集群

[flink@CNGULS038 flink]$  ./bin/start-cluster.sh
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Starting cluster.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Starting standalonesession daemon on host CNGULS038.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Starting taskexecutor daemon on host CNGULS038.

image.png

三、提交一个任务

Flink的发行版附带了多个示例作业。你可以将其中一个应用程序快速部署到正在运行的集群。

[flink@CNGULS038 flink]$ ./bin/flink run examples/streaming/WordCount.jar
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/flink/flink-1.12.2/lib/log4j-slf4j-impl-2.12.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/3.1.5.0-152/hadoop/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Executing WordCount example with default input data set.
Use --input to specify file input.
Printing result to stdout. Use --output to specify output path.
Job has been submitted with JobID 57d39dadc5a6d11449893803b8409c74
Program execution finished
Job with JobID 57d39dadc5a6d11449893803b8409c74 has finished.
Job Runtime: 551 ms

[flink@CNGULS038 flink]$ 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 来监视 集群和正在运行的作业的状态。

image.png

四、关闭集群

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

[flink@CNGULS038 flink]$ ./bin/stop-cluster.sh
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Stopping taskexecutor daemon (pid: 125394) on host CNGULS038.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Setting HBASE_CONF_DIR=/etc/hbase/conf because no HBASE_CONF_DIR was set.
Stopping standalonesession daemon (pid: 125038) on host CNGULS038.

看到这里的亲给个小红心,非常感谢

你可能感兴趣的:(本地安装)