在 Windows 上安装和运行 Flink1.9

下载 flink-1.9.0-bin-scala_2.12.tgz 。
这里使用的是当前的最新版 1.9.0

下载后解压到 D:\flink\flink-1.9.0 目录

运行 Flink 需要安装 Java 7.x 或更高的版本,操作系统需要 Win 7 或更高版本。

可以通过 java -version 确认 JDK 的版本, 1.7.x 或以上就可以了。

C:\Users\liujiajia>java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

执行 bin 目录下的 start-cluster.bat 文件启动 Flink。
看到有的文档上写的是执行 start-local.bat 文件,不过 1.9.0 版里没有该文件。

D:\flink\flink-1.9.0\bin>start-cluster.bat
Starting a local cluster with one JobManager process and one TaskManager process
.
You can terminate the processes via CTRL-C in the spawned shell windows.
Web interface by default on http://localhost:8081/.

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

4. 运行自带的 WordCount 示例

以统计 Flink 自带的 README.txt 文件为例。

cdD:\flink\flink-1.9.0\bin 目录执行如下命令:

D:\flink\flink-1.9.0\bin>flink.bat run D:\flink\flink-1.9.0\examples\batch\WordCount.jar -input D:\flink\flink-1.9.0\README.txt -output D:\flink\flink-1.9.0\README_CountWord_Result.txt

运行结果:

D:\flink\flink-1.9.0\bin>flink.bat run D:\flink\flink-1.9.0\examples\batch\WordC
ount.jar -input D:\flink\flink-1.9.0\README.txt -output D:\flink\flink-1.9.0\REA
DME_CountWord_Result.txt
log4j:WARN No appenders could be found for logger (org.apache.flink.client.cli.C
liFrontend).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in
fo.
Starting execution of program
Program execution finished
Job with JobID 411e8be6b27049d96bebd9f679d13b4a has finished.
Job Runtime: 371 ms

统计结果 README_CountWord_Result.txt 的内容如下:

1 1
13 1
5d002 1
740 1
about 1
account 1
administration 1
algorithms 1
and 7
another 1
any 2
apache 5
as 1
ask 1
asymmetric 1
at 1
before 1
bis 2
both 1
bureau 1
c 1
check 1
classified 1
code 2
com 1
commerce 1
commodity 1
concerning 1
control 1
country 3
cryptographic 2
currently 1
department 1
dev 1
distribution 2
eccn 1
eligible 1
enc 1
encryption 3
exception 2
export 5
flink 5
for 4
form 1
foundation 1
functions 1
github 2
government 1
has 1
have 2
http 2
https 1
if 2
import 2
in 1
includes 2
industry 1
information 3
is 1
it 1
latest 1
laws 1
license 1
lists 1
mailing 1
makes 1
manner 1
may 1
more 1
number 1
object 1
of 5
on 2
or 3
org 4
our 3
performing 1
permitted 1
please 2
policies 1
possession 2
questions 1
re 2
regulations 2
reside 1
restrictions 1
s 2
section 1
security 2
see 3
software 8
source 1
technology 1
the 8
this 4
to 2
tsu 1
u 1
under 1
unrestricted 1
use 2
user 1
using 2
visit 1
wassenaar 1
website 1
which 2
with 1
www 1
you 2
your 1

不将当前目录定位到 Flink 的话,运行 job 会报 The configuration directory was not specified. 错误。

C:\Users\liujiajia>D:\flink\flink-1.9.0\bin\flink.bat run D:\flink\flink-1.9.0\e
xamples\batch\WordCount.jar -input D:\flink\flink-1.9.0\README.txt -output D:\fl
ink\flink-1.9.0\README_CountWord_Result.txt
log4j:WARN No appenders could be found for logger (org.apache.flink.client.cli.C
liFrontend).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in
fo.
Exception in thread "main" java.lang.RuntimeException: The configuration directo
ry was not specified. Please specify the directory containing the configuration
file through the 'FLINK_CONF_DIR' environment variable.
        at org.apache.flink.client.cli.CliFrontend.getConfigurationDirectoryFrom
Env(CliFrontend.java:1117)
        at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1066)

Jobs -> Completed Jobs 菜单可以查看已完成的 Job。

在 Windows 上安装和运行 Flink1.9_第1张图片

版权声明:原创文章,未经允许不得转载。

你可能感兴趣的:(大数据~~Flink)