前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Flink】Flink环境搭建

【Flink】Flink环境搭建

作者头像
用户8682940
发布2022-09-02 13:16:28
9580
发布2022-09-02 13:16:28
举报
文章被收录于专栏:alexzhangalexzhang

本篇文章以最简单的方式快速搭建Flink 1.12.0环境,供开发学习使用。

1. Flink安装

1.1 下载地址

Flink版本列表:

https://archive.apache.org/dist/flink/

最新版1.12.0下载地址:

https://archive.apache.org/dist/flink/flink-1.12.0/flink-1.12.0-bin-scala_2.12.tgz

1.2 安装Flink

下载1.12.0版本:

wget https://archive.apache.org/dist/flink/flink-1.12.0/flink-1.12.0-bin-scala_2.12.tgz

1

解压下载下来的压缩包:

tar -xzf flink-1.12.0-bin-scala_2.12.tgz

1

启动:

./bin/start-cluster.sh

1

检查是否启动成功:

[root@localhost flink-1.12.0]# jps -l | grep flink

3922 org.apache.flink.runtime.taskexecutor.TaskManagerRunne

3615 org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint

1

2

3

检查web ui是否启动成功:

http://ip:port:8081

1

2. Flink示例运行

2.1 批处理例子

使用flink自带的word count程序实现单词计数,如果不输入任何参数(输入文件路径和输出文件路径),则使用程序内置的数据:

[root@localhost flink-1.12.0]# ./bin/flink run ./examples/batch/WordCount.jar --output /home/happy/flink/output/wordcount-result

Executing WordCount example with default input data set.

Use --input to specify file input.

Job has been submitted with JobID d1e96fab40dec4fffefa8b96674bd0ea

Program execution finished

Job with JobID d1e96fab40dec4fffefa8b96674bd0ea has finished.

Job Runtime: 168 ms

1

2

3

4

5

6

7

查看结果:

more ../output/wordcount-result

1

a 5

action 1

after 1

against 1

all 2

and 12

arms 1

arrows 1

......

1

2

3

4

5

6

7

8

9

2.2 流处理例子

安装netcat:

yum install -y nc

1

监听tcp端口,发送数据:

nc -l 8881

1

启动流处理示例程序:

[root@localhost flink-1.12.0]# ./bin/flink run ./examples/streaming/SocketWindowWordCount.jar --port 8881

Job has been submitted with JobID 41831fee1253dc7cd4a1e4dfee357916

1

2

3

发送数据:

aa bb bb cc

1

控制台输出结果::

cc : 1

aa : 1

cc : 1

bb : 2

1

2

3

4

2.3 Flink UI

内置的web-ui,默认端口为8081:

http://ip:port:8081

1

我们可以通过这也界面来提交和监控Flink程序,以及查看运行日志等等。

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
大数据
全栈大数据产品,面向海量数据场景,帮助您 “智理无数,心中有数”!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档