欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本文实战Flink1.7的安装和Demo运行过程; 步骤介绍 准备工作; 下载Flink1.7; 安装Flink1.7;
欢迎访问我的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
体验Flink1.7
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
欢迎关注51CTO博客:程序员欣宸
学习路上,你不孤单,欣宸原创一路相伴...
【本文转自:
韩国服务器 https://www.68idc.cn 复制请保留原URL】