pacemaker架构分析
简要介绍
Pacemaker是 Linux环境中使用最为广泛的开源集群资源管理器。
pacemaker集群架构
一个pacemaker集群通常包括以下部分(Pacemaker stack)
-
Resources: These are the reason for the cluster’s being — the services that need to be kept highly available.
集群存在的目的就是为了管理Resources,比如虚拟ip服务,文件系统服务,数据库服务,都可以称之为资源
-
Resource agents: These are scripts or operating system components that start, stop, and monitor resources, given a set of resource parameters. These provide a uniform interface between Pacemaker and the managed services.
作为Pacemaker和托管服务之间的统一接口,通常由启动,停止和监视资源的脚本和操作系统组件构成
-
Fence agents: These are scripts that execute node fencing actions, given a target and fence device parameters.
作为一种确保节点无法运行服务的能力,可以通过隔离设备(例如切断目标电源的智能电源开关或切断目标设备对本地网络的访问的智能网络开关)来实现。
-
Cluster membership layer: This component provides reliable messaging, membership, and quorum information about the cluster. Currently, Pacemaker supports Corosync as this layer.
提供有关群集的可靠消息传递,成员资格和仲裁信息,支持corosync作为Cluster membership layer
-
Cluster resource manager: Pacemaker provides the brain that processes and reacts to events that occur in the cluster. These events may include nodes joining or leaving the cluster; resource events caused by failures, maintenance, or scheduled activities; and other administrative actions. To achieve the desired availability, Pacemaker may start and stop resources and fence nodes.
作为集群资源管理的大脑,管理集群节点的加入和删除,处理各类资源事件,启停资源以及隔离故障节点
-
Cluster tools: These provide an interface for users to interact with the cluster. Various command-line and graphical (GUI) interfaces are available.
提供与集群的交互入口,有命令行工具,也有GUI工具
大多数托管服务本身并不支持群集。但是,许多流行的开源群集文件系统都使用通用的分布式锁管理器(DLM),该方法直接将Corosync用于其消息传递和成员资格功能,并使用Pacemaker来隔离节点。
Pacemaker自身结构
Pacemaker itself is composed of multiple daemons that work together:
-
pacemakerd
作为Pacemaker主进程,会生成所有其他守护程序,并在它们意外退出时重新生成它们。
-
pacemaker-attrd
维护所有节点的属性数据,使其在整个群集中保持同步,并处理修改它们的请求,这些属性通常记录在CIB中。
-
pacemaker-based(CIB)
是在内存中的XML数据库,保存了cluster的所有节点和资源的配置和状态。我们查询出来的configuration都是保存在CIB里面。
-
pacemaker-controld
控制器,对于resource做的任何操作都是通过它,维护集群成员的一致视图和编排所有其他组件。
-
pacemaker-execd
负责在本地执行Resource agents并返回结果
-
pacemaker-fenced
在给定目标节点后,执行Fence agents隔离故障节点并返回执行结果
-
pacemaker-schedulerd
调度程序,以给定CIB快照作为输入,由pacemaker-schedulerd确定实现集群所需状态所需的操作
Pacemaker集群通过选择一个控制器实例作为“ 指定控制器”(DC)来作为整个集群的大脑。如果选择的DC进程(或其所在的节点)失败,则会快速建立一个新进程。
DC响应集群事件的方法是获取CIB的当前快照,将其提供给调度程序,然后要求集群各节点的执行程序(pacemaker-execd)(直接在本地节点上执行,或向其它节点的控制器发送请求)和pacemaker-fenced程序执行任何必要的操作。
但行好事,莫问前程