乐趣区

关于flink:Flink的standalone和HA安装部署

1、standalone cluster 部署

flink 的集群也是主从架构。主是 jobManager,, 从事 taskManager。

布局:

ip 服务形容 192.168.216.111jobManager、taskManager192.168.216.112taskManager192.168.216.113taskManager

1、下载

2、解压
[root@hadoop01 local]# tar -zxvf /home/flink-1.9.1-bin-scala_2.11.tgz -C /usr/local/
[root@hadoop01 local]# cd ./flink-1.9.1/

3、配置环境变量
export FLINK_HOME=/usr/local/flink-1.9.1/export
PATH=$PATH:$JAVA_HOME/bin:$ZK_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$KAFKA_HOME/bin:$FLINK_HOME/bin:

4、刷新环境变量
[root@hadoop01 flink-1.9.1]# source /etc/profile
[root@hadoop01 flink-1.9.1]# which flink

5、集群配置

配置三个配置文件
-rw-r–r–. 1 yarn games 10327 Jul 18 2019 flink-conf.yaml
-rw-r–r–. 1 yarn games 15 Jul 15 2019 masters-rw
-r–r–. 1 yarn games 10 Jul 15 2019 slaves

配置 flink-conf.yaml:

批改几个中央:

jobmanager.rpc.address: hadoop01
rest.port: 8081
rest.address: hadoop01

配置 masters:
hadoop01:8081

配置 slaves:
hadoop01
hadoop02
hadoop03

6、散发到别的服务器
[root@hadoop01 flink-1.9.1]# scp -r ../flink-1.9.1/ hadoop02:/usr/local/
[root@hadoop01 flink-1.9.1]# scp -r ../flink-1.9.1/ hadoop03:/usr/local/ 并配置好其余服务器的环境变量。。。。。。

7、启动集群
[root@hadoop01 flink-1.9.1]# start-cluster.sh

[root@hadoop01 flink-1.9.1]# jps2080 ResourceManager1684 NameNode5383 StandaloneSessionClusterEntrypoint1803 DataNode2187 NodeManager5853 TaskManagerRunner 拜访 web:http://hadoop01:8081/#/overview

8、运行作业
[root@hadoop01 flink-1.9.1]# flink run ./examples/batch/WordCount.jar
–input /home/words –output /home/1907/out/02Starting execution of programProgram execution finishedJob with JobID dd30661b01cc6f663fe22dab7d7ef542 has finished.Job Runtime: 6432 ms

查看后果:
[root@hadoop01 flink-1.9.1]# cat /home/1907/out/02

生产中:

1、jobmamager 配置到独自服务器即可,,,自身应用不了多少内存。

2、taskmamager 配置多台服务器,内存短缺,可能满足业务即可。

2、standalone cluster HA 部署基于 standalone cluster 集群降级部署。

1、批改配置:

flink-conf.yamlhigh-availability: zookeeperhigh-availability.zookeeper.quorum: hadoop01:2181,hadoop02:2181,hadoop03:2181high-availability.zookeeper.path.root: /flinkhigh-availability.cluster-id: /cluster_flinkhigh-availability.storageDir: hdfs://hadoop01:9000/flink/recovery

2、批改配置:

mastershadoop01:8081hadoop02:8081

3、启动集群

启动程序:先启动 zk 和 hdfs、再启动 flink。

拷贝 hdfs 的依赖包:[root@hadoop01 ~]# cp /home/flink-shaded-hadoop-2-uber-2.7.5-10.0.jar /usr/local/flink-1.9.1/lib/[root@hadoop01 ~]# scp /home/flink-shaded-hadoop-2-uber-2.7.5-10.0.jar hadoop02:/usr/local/flink-1.9.1/lib/[root@hadoop01 ~]# scp /home/flink-shaded-hadoop-2-uber-2.7.5-10.0.jar hadoop03:/usr/local/flink-1.9.1/lib/ 启动集群:[root@hadoop01 ~]# start-cluster.sh

4、测试提交作业:

[root@hadoop01 ~]# flink run /usr/local/flink-1.9.1/examples/batch/WordCount.jar –input /home/words –output /home/out/fl00

后果:

[root@hadoop01 ~]# cat /home/out/fl001813 4gp1813 3hello 2hi 1

5、并测试 HA 的切换:

通过 log 查看 leader 还是 standby

状态:hadoop01 的日志

由上能够看出 hadoop01 是 leader。也就是 active 状态。hadoop02 的日志

hadoop02 的日志没有 leadership 标识,也就是为 standby 状态。手动杀死 hadoop01 激活状态的 jobmanager:

[root@hadoop01 ~]# jps3840 TaskManagerRunner2454 NodeManager1959 NameNode3385 StandaloneSessionClusterEntrypoint1802 QuorumPeerMain4026 Jps2092 DataNode2350 ResourceManager
[root@hadoop01 ~]# kill -9 3385 ## 或者应用 jobmanager.sh stop 再次查看 hadoop02 的 log:

显示 hadoop02 为 leader 状态。测试是否能跑作业:

后果查看:

6、重启 hadoop01 的 jobmanager:

[root@hadoop01 flink-1.9.1]# jobmanager.sh startStarting standalonesession daemon on host hadoop01.[root@hadoop01 flink-1.9.1]# jps3840 TaskManagerRunner5408 StandaloneSessionClusterEntrypoint 查看 hadoop01 的日志状态:

没有那个受权 leader 信息,代表就是一个 standby 状态咯。HA 的失常切换性能就能够咯。到此为之,咱们的 local 模式、standalone cluster 和 standalone cluster HA 部署实现。

退出移动版