Flink1.7从安装到体验
【摘要】 本文实战Flink1.7的安装和Demo运行过程
欢迎访问我的GitHub
这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
- 本文实战Flink1.7的安装和Demo运行过程;
步骤介绍
- 准备工作;
- 下载Flink1.7;
- 安装Flink1.7;
- 启动Flink1.7;
- 体验Flink1.7;
准备工作
- 以下是本次实战的环境信息:
- 操作系统:CentOS Linux release 7.5.1804
- JDK:1.8.0_191
- nc工具:7.50(安装命令是yum install nmap-ncat.x86_64)
- 注意:
- 我在vmware的ubuntu16上试过,启动后Managers、Slots、Available Task Slots的数量都为零,但在实体机器上是没有问题的;
- CentOS请注意关闭防火墙;
下载Flink1.7
- 在Flink官网下载,地址是:https://flink.apache.org/downloads.html
- 如下图,选择红框中的版本:
安装Flink1.7
- Flink1.7的安装很简单,解压即可,如下所示:
- 下载的Flink安装包文件是flink-1.7.0-bin-hadoop28-scala_2.11.tgz,放在此位置:/usr/local/work;
- 在/usr/local/work目录下执行命令tar -zxvf flink-1.7.0-bin-hadoop28-scala_2.11.tgz解压,会生成一个文件夹:flink-1.7.0
启动Flink1.7
- 在文件夹flink-1.7.0下执行命令./bin/start-cluster.sh即可启动Flink,启动信息如下:
[root@vostro flink-1.7.0]# ./bin/start-cluster.sh
Starting cluster.
Starting standalonesession daemon on host vostro.
Starting taskexecutor daemon on host vostro.
- 在flink-1.7.0/log目录下可以看到名为flink-root-standalonesession-0-vostro.log的日志文件(您的文件名和我这里略有不同,vostro是我的主机名,root是当前账号),内容如下:
2018-12-16 16:51:00,658 INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - Rest endpoint listening at localhost:8081
2018-12-16 16:51:00,658 INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - http://localhost:8081 was granted leadership with leaderSessionID=00000000-0000-0000-0000-000000000000
2018-12-16 16:51:00,658 INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - Web frontend listening at http://localhost:8081.
2018-12-16 16:51:00,760 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService - Starting RPC endpoint for org.apache.flink.runtime.resourcemanager.StandaloneResourceManager at akka://flink/user/resourcemanager .
2018-12-16 16:51:00,777 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService - Starting RPC endpoint for org.apache.flink.runtime.dispatcher.StandaloneDispatcher at akka://flink/user/dispatcher .
2018-12-16 16:51:00,803 INFO org.apache.flink.runtime.resourcemanager.StandaloneResourceManager - ResourceManager akka.tcp://flink@localhost:6123/user/resourcemanager was granted leadership with fencing token 00000000000000000000000000000000
2018-12-16 16:51:00,804 INFO org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager - Starting the SlotManager.
2018-12-16 16:51:00,847 INFO org.apache.flink.runtime.dispatcher.StandaloneDispatcher - Dispatcher akka.tcp://flink@localhost:6123/user/dispatcher was granted leadership with fencing token 00000000-0000-0000-0000-000000000000
2018-12-16 16:51:00,849 INFO org.apache.flink.runtime.dispatcher.StandaloneDispatcher - Recovering all persisted jobs.
2018-12-16 16:51:01,601 INFO org.apache.flink.runtime.resourcemanager.StandaloneResourceManager - Registering TaskManager with ResourceID a0692f62811e0452256484a5e46ec5ed (akka.tcp://flink@vostro:40228/user/taskmanager_0) at ResourceManager
2018-12-16 17:19:09,663 INFO org.apache.flink.runtime.entrypoint.ClusterEntrypoint - RECEIVED SIGNAL 15: SIGTERM. Shutting down as requested.
2018-12-16 17:19:09,663 INFO org.apache.flink.runtime.blob.TransientBlobCache - Shutting down BLOB cache
2018-12-16 17:19:09,668 INFO org.apache.flink.runtime.blob.BlobServer - Stopped BLOB server at 0.0.0.0:35234
-
我的机器IP地址为192.168.1.103,因此在浏览器访问http://192.168.1.103:8081,可以见到如下信息:
-
至此,Flink1.7安装、部署、启动完成;
体验Flink1.7
- 在机器上执行以下命令连接本机9000端口:
nc -l 9000
- 在文件夹flink-1.7.0下执行以下命令,即可监听本机9000端口,等待该端口的数据:
./bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000
- 此时再去刷新web页面,可见如下信息,新增了一个Job:
- 在执行了nc -l 9000命令的窗口,输入一些句子,每输完一个就按下回车键,如下:
[root@vostro work]# nc -l 9000
hello flink world
aaa bbb ccc
flink start
start flink study, flink go
- 这样就将上述字符串发送到本机9000端口;
- 在flink-1.7.0/log目录下,会有flink-root-taskexecutor-0-vostro.out文件出现,您的文件名可能略有不同,其中vostro是我这边的主机名,root是当前账号,打开这个文件看看,出现以下内容:
[root@vostro work]# nc -l 9000
hello flink world
aaa bbb ccc
flink start
start flink study, flink go
-
可见任务已正常执行,每个句子中的单词数量都被统计出来了;
-
至此,我们完成了Flink的初体验,在后续的实战中咱们再一起逐渐深入的体验Flink这个强大的框架;
欢迎关注华为云博客:程序员欣宸
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)