1. 程式人生 > >flink安裝以及執行自帶wordcount示例(單機版,無hadoop環境)

flink安裝以及執行自帶wordcount示例(單機版,無hadoop環境)

1、下載安裝包到/opt目錄

2、解壓安裝包

tar zxf flink-1.6.1-bin-hadoop26-scala_2.11.tgz 

3、啟動flink

cd /opt/flink-1.6.1/bin

[[email protected] bin]# ./start-cluster.sh 
Starting cluster.
Starting standalonesession daemon on host localhost.localdomain.
Starting taskexecutor daemon on host localhost.localdomain.

此時可以開啟瀏覽器在8081埠檢視flink的web

執行wordcount示例

1、在控制檯視窗1中啟動一個本地服務nc -l -p 9000

2、在控制檯視窗2中提交flink程式bin/flink run examples/streaming/SocketWindowWordCount.jar   --hostname localhost    Starting execution of program

說明:該程式每隔5秒統計一次接收的資料中的單詞個數

3、在控制檯視窗3中開啟out日誌檔案     log目錄下的out檔案會統計flink的執行結果。cd /opt/flink-1.6.1/log tail -f flink-root-taskexecutor-0-localhost.localdomain.out

out檔案更新後會控制檯中會自動顯示新增的資料。

4、在控制檯1中輸入語句,在控制檯3中檢視統計結果,如下圖所示:

5、在flink的web中檢視執行的job