Flink HA

07-19 1020阅读

目录

Flink HA集群规划

环境变量配置

masters配置

 测试


Flink HA集群规划

        FLink HA集群规划如下:

IP地址主机名称Flink角色ZooKeeper角色
192.168.128.111bigdata111masterQuorumPeerMain
192.168.128.112bigdata112worker、masterQuorumPeerMain
192.168.128.113bigdata113workerQuorumPeerMain

 bigdata111和bigdata112作为master节点,也就是实现JobManager的高可用。bigdata112和bigdata113作为worker节点,作为TaskManager节点。Flink HA集群使用ZooKeeper和HDFS实现。所以需要ZooKeeper集群和HDFS集群。假设已经部署好了ZooKeeper集群和HDFS集群。


环境变量配置

        执行如下命令,打开配置文件

 vi /etc/profile

在文件末尾添加如下配置内容:

export HADOOP_CLASSPATH=`hadoop classpath`

执行如下命令,生效配置文件: 

source /etc/profile

三台服务器同时配置。


masters配置

        进去Flink安装目录下的conf目录,如图:

Flink HA

masters配置文件内容改为: 

bigdata111:8081
bigdata112:8081

将该配置同步到其他服务器,保持三台服务器相同配置。

scp -r masters bigdata112:`pwd`
scp -r masters bigdata113:`pwd`

复制成功后,如图: 

Flink HA

        进入Flink安装目录下的conf目录,如图:

Flink HA

打开配置文件,Flink HA的默认配置如下: 

Flink HA

将HA配置修改为如下内容: 

# The high-availability mode. Possible options are 'NONE' or 'zookeeper'.
#
high-availability: zookeeper
# The path where metadata for master recovery is persisted. While ZooKeeper stores
# the small ground truth for checkpoint and leader election, this location stores
# the larger objects, like persisted dataflow graphs.
#
# Must be a durable file system that is accessible from all nodes
# (like HDFS, S3, Ceph, nfs, ...)
#
high-availability.storageDir: hdfs:///flink/ha/
# The list of ZooKeeper quorum peers that coordinate the high-availability
# setup. This must be a list of the form:
# "host1:clientPort,host2:clientPort,..." (default clientPort: 2181)
#
high-availability.zookeeper.quorum: bigdata111:2181,bigdata112:2181,bigdata113:2181
# ACL options are based on https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_BuiltinACLSchemes
# It can be either "creator" (ZOO_CREATE_ALL_ACL) or "open" (ZOO_OPEN_ACL_UNSAFE)
# The default value is "open" and it can be changed to "creator" if ZK security is enabled
#
# high-availability.zookeeper.client.acl: open

将该配置文件同步到其他服务器,命令如下:

scp -r flink-conf.yaml bigdata112:`pwd`
scp -r flink-conf.yaml bigdata113:`pwd`

同步成功后,如图: 

Flink HA

 测试

        先后启动ZooKeeper集群、HDFS集群和flink集群,如图:

Flink HA

Flink HA

Flink HA

Flink HA

使用浏览器分别登录Flink web ui页面:

http://bigdata111:8081/#/overview

http://bigdata112:8081/#/overview

如图: 

Flink HA

Flink HA

页面上无法区分哪个节点是active。HDFS上同时生成了HA的数据目录,如图:

Flink HA

下面从ZooKeeper中查看哪一个节点是active:

        执行zkCli.sh命令连接ZooKeeper集群,最终查找到当前Flink中active JobManager是bigdata111。如图:

Flink HA

 现在在bigdata111上运行flink应用程序,命令如下:

flink run -c com.leboop.SocketStreamingWordCount /root/jars/flink-1.0-SNAPSHOT.jar --host bigdata111 --port 9999

运行成功后如图:

Flink HA

此时在bigdata111和bigdata112上的web ui上均可以看到相同的正在运行的任务,如图: 

Flink HA

Flink HA

现在将bigdata111上的JobManager杀死,如图:

Flink HA

此时bigdata111无法打开web ui页面,如图:

Flink HA

可以打开bigdata112的web ui页面,如图: 

Flink HA

再次执行zkCli.sh命令,连接到ZooKeeper集群,查看节点信息如下: Flink HA

active JobManager节点已经切换到bigdata112。 

VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]