这是我参与「第四届青训营 」笔记创作活动的的第3天
[第四届青训营笔记创作活动]
编译
环境准备
CendOS 7.4
Git
JDK 1.8
Maven 3.6.3
npm 8.5.5
一、源码下载
执行命令
git clone github.com/apache/flin…
cd flink
二、编译
-
首先 cd 到 flink-runtime-web/web-dashboard/ 目录下,并执行命令
cd flink-runtime-web/web-dashboard/ npm install
cd flink-runtime-web/web-dashboard/ npm run build -
将 flink-runtime-web 目录下的 pom.xml 中的 ci --cache-max=0 --no-save 替换为 install -registry=registry.npm.taobao.org --cache-max=0 --no-save
sed -i 's/ci --cache-max=0 --no-save/install -registry=https:\/\/registry.npm.taobao.org --cache-max=0 --no-save/' flink-runtime-web/pom.xml
-
在 flink 目录下开始编译
mvn clean install -DskipTests
-
编译过程中若出现依赖错误可在 Index of /groups/snapshots/org/apache/flink 自行下载
-
编译完成,Flink is now installed in
build-target.
部署
一、部署模式及环境准备
-
部署模式
- Standalone 单机模式
- 集群模式
- Flink on Yarn
-
环境准备
- 三台虚拟机 hadoop102、hadoop103、hadoop104 并配置免密登录,做好主机映射(集群模式)
- zookeeper 3.5.9(Flink on Yarn)
- hadoop 3.1.3(Flink on Yarn)
-
部署
-
Standalone 单机模式
进入build-target目录直接启动即可cd build-target/
bin/start-cluster.sh访问 hostname:8081 进入flink webUI
-
集群模式
-
修改 conf/flink-conf.yaml 文件,修改如下内容
jobmanager.rpc.address: hadoop102
rest.port: 8081
rest.address: hadoop102
rest.bind-address: hadoop102 -
修改 conf/masters 配置master节点,修改为
hadoop102:8081
-
修改 conf/workers,修改为
hadoop102 hadoop103 hadoop104
-
分发到另外两台机器
xsync ./
-
在 hadoop102 上启动集群
./bin/start-cluster.sh
-
-
-
测试
-
验证是否flink已经启动
[GambleMonster@hadoop102 flink]$ jps
79073 TaskManagerRunner
79185 Jps
78728 StandaloneSessionClusterEntrypointflink 已经启动
-
打开另一个界面输入如下指令
nc -l 9000
-
启动 example 测试
./bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000
-
监控日志
tail -f log/flink-GambleMonster-taskexecutor-0-hadoop102.log
-
在另一个界面向9000端口发送数据
hello
hello
flink -
可以看到日志输出
hello : 1
hello : 1
flink : 1
-
至此 flink 已经部署完成