入门flink---测试demo

1下载flink

下载链接
在这里插入图片描述

2启动flink

 ./start-cluster.sh 
[jackray@localhost ~]$ cd flink-1.9.2/
[jackray@localhost flink-1.9.2]$ ls
bin  conf  examples  lib  LICENSE  licenses  log  NOTICE  opt  plugins  README.txt
[jackray@localhost flink-1.9.2]$ cd bin
[jackray@localhost bin]$ ls
config.sh           historyserver.sh           pyflink-shell.sh      start-zookeeper-quorum.sh
find-flink-home.sh  jobmanager.sh              sql-client.sh         stop-cluster.sh
flink               mesos-appmaster-job.sh     standalone-job.sh     stop-zookeeper-quorum.sh
flink.bat           mesos-appmaster.sh         start-cluster.bat     taskmanager.sh
flink-console.sh    mesos-taskmanager.sh       start-cluster.sh      yarn-session.sh
flink-daemon.sh     pyflink-gateway-server.sh  start-scala-shell.sh  zookeeper.sh
[jackray@localhost bin]$ ./start-cluster.sh 
Starting cluster.
Starting standalonesession daemon on host localhost.localdomain.
Starting taskexecutor daemon on host localhost.localdomain.

验证是否flink已经启动

[jackray@localhost bin]$ jps
3091 Jps
2601 StandaloneSessionClusterEntrypoint
3035 TaskManagerRunner

访问flink web

http://192.168.0.130:8081

在这里插入图片描述
flink已经启动。

3测试demo

打开一个界面输入如下指令

[jackray@localhost bin]$ nc -l 9000

启动example

[jackray@localhost flink-1.9.2]$ ./bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000
Starting execution of program
Program execution finished
Job with JobID 5a2f66ccd20e5b398f13b33791a4b7a3 has finished.
Job Runtime: 1022467 ms

测试
输入字符,回车即为输入成功

[jackray@localhost bin]$ nc -l 9000
hello\^H
hello
flink

日志中查看打印输出

hello : 1
hello : 1
flink : 1

具体操作日志如下

[jackray@localhost flink-1.9.2]$ cd log/
[jackray@localhost log]$ ls
flink-jackray-client-localhost.localdomain.log               flink-jackray-standalonesession-0-localhost.localdomain.out  flink-jackray-taskexecutor-0-localhost.localdomain.out
flink-jackray-standalonesession-0-localhost.localdomain.log  flink-jackray-taskexecutor-0-localhost.localdomain.log
[jackray@localhost log]$ tail -f flink-jackray-taskexecutor-0-localhost.localdomain.log 
2020-02-08 22:33:59,468 INFO  org.apache.flink.runtime.taskmanager.Task                     - Creating FileSystem stream leak safety net for task Window(TumblingProcessingTimeWindows(5000), ProcessingTimeTrigger, ReduceFunction$1, PassThroughWindowFunction) -> Sink: Print to Std. Out (1/1) (c2aaba677f2affe819cef4d4c9366db2) [DEPLOYING]
2020-02-08 22:33:59,487 INFO  org.apache.flink.runtime.taskmanager.Task                     - Loading JAR files for task Window(TumblingProcessingTimeWindows(5000), ProcessingTimeTrigger, ReduceFunction$1, PassThroughWindowFunction) -> Sink: Print to Std. Out (1/1) (c2aaba677f2affe819cef4d4c9366db2) [DEPLOYING].
2020-02-08 22:33:59,488 INFO  org.apache.flink.runtime.taskmanager.Task                     - Registering task at network: Window(TumblingProcessingTimeWindows(5000), ProcessingTimeTrigger, ReduceFunction$1, PassThroughWindowFunction) -> Sink: Print to Std. Out (1/1) (c2aaba677f2affe819cef4d4c9366db2) [DEPLOYING].
2020-02-08 22:33:59,598 INFO  org.apache.flink.runtime.taskmanager.Task                     - Window(TumblingProcessingTimeWindows(5000), ProcessingTimeTrigger, ReduceFunction$1, PassThroughWindowFunction) -> Sink: Print to Std. Out (1/1) (c2aaba677f2affe819cef4d4c9366db2) switched from DEPLOYING to RUNNING.
2020-02-08 22:33:59,616 INFO  org.apache.flink.runtime.taskmanager.Task                     - Source: Socket Stream -> Flat Map (1/1) (b518c8f29e6631d6753c22a8e93a9d9f) switched from DEPLOYING to RUNNING.
2020-02-08 22:33:59,619 INFO  org.apache.flink.streaming.runtime.tasks.StreamTask           - No state backend has been configured, using default (Memory / JobManager) MemoryStateBackend (data in heap memory / checkpoints to JobManager) (checkpoints: 'null', savepoints: 'null', asynchronous: TRUE, maxStateSize: 5242880)
2020-02-08 22:33:59,626 INFO  org.apache.flink.streaming.runtime.tasks.StreamTask           - No state backend has been configured, using default (Memory / JobManager) MemoryStateBackend (data in heap memory / checkpoints to JobManager) (checkpoints: 'null', savepoints: 'null', asynchronous: TRUE, maxStateSize: 5242880)
2020-02-08 22:33:59,759 WARN  org.apache.flink.metrics.MetricGroup                          - The operator name Window(TumblingProcessingTimeWindows(5000), ProcessingTimeTrigger, ReduceFunction$1, PassThroughWindowFunction) exceeded the 80 characters length limit and was truncated.
2020-02-08 22:33:59,770 INFO  org.apache.flink.streaming.api.functions.source.SocketTextStreamFunction  - Connecting to server socket localhost:9000
2020-02-08 22:33:59,786 INFO  org.apache.flink.runtime.state.heap.HeapKeyedStateBackend     - Initializing heap keyed state backend with stream factory.
^Z
[1]+  Stopped                 tail -f flink-jackray-taskexecutor-0-localhost.localdomain.log
[jackray@localhost log]$ tail -f flink-jackray-taskexecutor-0-localhost.localdomain.out 
hello : 1
hello : 1
flink : 1

发布了434 篇原创文章 · 获赞 58 · 访问量 31万+

猜你喜欢

转载自blog.csdn.net/ppwwp/article/details/104235259