centos 8 flinkをインストールしwordcountをテスト
開発環境と必要なソフトウェア centos 8 java flink
flinkのインストール
インストールを選択したのはflinkの現在の最新バージョン1.9です.インストール前にjavaが正常にインストールされていることを確認してください.javaがインストールされているかどうかを確認 flinkバイナリパッケージのダウンロード flinkバイナリパッケージを/usr/local に解凍flinkの起動と停止のコマンド flinkを起動 flinkを停止 flinkを起動したら、curlコマンドを使用して、flinkが持っているWeb管理ページを表示して、flinkが正常に起動したかどうかを確認できます wordcountプログラムのテスト
flink自体は私たちのために多くのテストサンプルを持ってきて、サンプルはすべてflinkプロジェクトのexamplesフォルダの中に置いて、flink自身がとても流式計算が得意なため、私たちはわざわざexamples/streamingの下の流式計算のサンプルSocketWindowWordCount.jarを選んでflinkの機能を実証しますストリームのサンプルであるため、まずストリームを構築し、私たちのサンプルではSocketをストリームとして使用します ローカルの9000ポートを傍受 worlcountプログラムを実行 ncで動作するshellは以下のような文字で、リターン を押してください.flink/logディレクトリの下でtail-f flink*.outを実行すると、flinkがhelloのworldが2回現れたことを統計するのに成功したことがわかります.一回 が現れる
flinkのインストール
インストールを選択したのはflinkの現在の最新バージョン1.9です.インストール前にjavaが正常にインストールされていることを確認してください.
[vagrant@3b5a73745ce45650 ~]$ java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
[vagrant@3b5a73745ce45650 ~]$ wget http://mirror.bit.edu.cn/apache/flink/flink-1.9.1/flink-1.9.1-bin-scala_2.11.tgz
--2019-12-25 15:24:32-- http://mirror.bit.edu.cn/apache/flink/flink-1.9.1/flink-1.9.1-bin-scala_2.11.tgz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117, 2001:da8:204:1205::22
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 255543307 (244M) [application/octet-stream]
Saving to: ‘flink-1.9.1-bin-scala_2.11.tgz’
flink-1.9.1-bin-scala_2.11.tgz 100%[=======================================================================================================>] 243.71M 3.06MB/s in 65s
2019-12-25 15:25:37 (3.74 MB/s) - ‘flink-1.9.1-bin-scala_2.11.tgz’ saved [255543307/255543307]
sudo tar -zxvf flink-1.9.1-bin-scala_2.11.tgz -C /usr/local
cd /usr/local
sudo mv flink-1.9.1/ flink
sudo ./flink/bin/start-cluster.sh
sudo ./flink/bin/stop-cluster.sh
[vagrant@3b5a73745ce45650 ~]$ curl 127.0.0.1:8081
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Apache Flink Web Dashboard</title>
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" href="assets/favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="assets/favicon/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="assets/favicon/manifest.json">
<link rel="mask-icon" href="assets/favicon/safari-pinned-tab.svg" color="#aa1919">
<link rel="shortcut icon" href="assets/favicon/favicon.ico">
<meta name="msapplication-config" content="assets/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<base href="./"><link rel="stylesheet" href="styles.30d0912c1ece284d8d9a.css"></head>
<body>
<flink-root></flink-root>
<script type="text/javascript" src="runtime.440aa244803781d5f83e.js"></script><script type="text/javascript" src="es2015-polyfills.5e343224e81eefb7658e.js" nomodule></script><script type="text/javascript" src="polyfills.b37850e8279bc3caafc9.js"></script><script type="text/javascript" src="main.69b429cff67b392733d5.js"></script></body>
</html>
flink自体は私たちのために多くのテストサンプルを持ってきて、サンプルはすべてflinkプロジェクトのexamplesフォルダの中に置いて、flink自身がとても流式計算が得意なため、私たちはわざわざexamples/streamingの下の流式計算のサンプルSocketWindowWordCount.jarを選んでflinkの機能を実証します
nc -l 9000
cd /usr/local/flink
sudo bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000
[vagrant@3b5a73745ce45650 ~]$ nc -l 9000
hello world! hello
[vagrant@3b5a73745ce45650 log]$ tail -f flink*.out
==> flink-root-standalonesession-1-3b5a73745ce45650.out <==
==> flink-root-taskexecutor-1-3b5a73745ce45650.out <==
hello : 2
world! : 1