一 渣玲、下載
為了能夠運(yùn)行Flink,唯一的要求是有一個(gè)可以正常工作的的 Java8 或 Java11的環(huán)境。你可以通過以下命令來檢查java 環(huán)境是否被正確的安裝拳亿。
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
二、啟動(dòng)一個(gè) cluster
Flink自帶了一個(gè)單獨(dú)的腳本來啟動(dòng)一個(gè)本地集群
[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.
三愿伴、提交一個(gè)任務(wù)
Flink的發(fā)行版附帶了多個(gè)示例作業(yè)肺魁。你可以將其中一個(gè)應(yīng)用程序快速部署到正在運(yùn)行的集群。
[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 來監(jiān)視 集群和正在運(yùn)行的作業(yè)的狀態(tài)鹅经。
四、關(guān)閉集群
任務(wù)完成之后官帘,可以快速停止集群和所有正在運(yùn)行的組件瞬雹。
[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.
看到這里的親給個(gè)小紅心,非常感謝