Pacemaker是Red Hat High Availability Add-on的一部分。在RHEL上进行试用的最简单方法是从Scientific Linux 或CentOS存储库中进行安装

环境准备

双节点

注:centos修改主机名

临时修改:hostname 主机名  --立即生效

永久修改:hostnamectl set-hostname 主机名  --重启生效

node1 - 192.168.29.246
node2 - 192.168.29.247

系统信息

CentOS Linux release 7.8. (Core)

安装

所有节点使用yum安装Pacemaker以及我们将需要的一些其他必要软件包

yum install pacemaker pcs resource-agents

创建集群

所有节点启动pcs守护进程并设置开机运行

systemctl start pcsd.service
systemctl enable pcsd.service

设置pcs所需的身份验证

#所有节点执行
echo 123456 | passwd --stdin hacluster #主节点执行
pcs cluster auth node1 node2 -u hacluster -p 123456 --force

开始创建

pcs cluster setup --force --name pacemaker1 node1 node2

过程信息如下:

[root@node1 ~]# pcs cluster setup --force --name pacemaker1 node1 node2
Destroying cluster on nodes: node1, node2...
node1: Stopping Cluster (pacemaker)...
node2: Stopping Cluster (pacemaker)...
node1: Successfully destroyed cluster
node2: Successfully destroyed cluster

Sending 'pacemaker_remote authkey' to 'node1', 'node2'
node1: successful distribution of the file 'pacemaker_remote authkey'
node2: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
node1: Succeeded
node2: Succeeded

Synchronizing pcsd certificates on nodes node1, node2...
node1: Success
node2: Success
Restarting pcsd on the nodes in order to reload the certificates...
node1: Success
node2: Success

启动集群

任一节点执行

pcs cluster start --all

启动信息

[root@node1 ~]# pcs cluster start --all
node1: Starting Cluster (corosync)...
node2: Starting Cluster (corosync)...
node1: Starting Cluster (pacemaker)...
node2: Starting Cluster (pacemaker)...

集群设置

禁用Fencing

pcs property set stonith-enabled=false

因为只有两个节点,仲裁没有意义,所以我们禁用仲裁

pcs property set no-quorum-policy=ignore

强制集群在单个故障后移动服务

pcs resource defaults migration-threshold=

添加资源

pcs resource create my_first_svc ocf:heartbeat:Dummy op monitor interval=60s

my_first_svc:服务名

ocf:pacemaker:Dummy:需要使用的脚本(Dummy- 一种用作模板以及对此类指南有用的代理)

op monitor interval = 60s 告诉Pacemaker通过调用代理的Monitor操作每1分钟检查一次此服务的运行状况

查看集群状态

[root@node1 ~]# pcs status
Cluster name: pacemaker1
Stack: corosync
Current DC: node1 (version 1.1.-.el7-f14e36fd43) - partition with quorum
Last updated: Sat Jun ::
Last change: Sat Jun :: by root via cibadmin on node1 nodes configured
resource configured Online: [ node1 node2 ] Full list of resources: my_first_svc (ocf::heartbeat:Dummy): Started node1 Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
[root@node1 ~]# crm_mon -
Stack: corosync
Current DC: node1 (version 1.1.-.el7-f14e36fd43) - partition with quorum
Last updated: Sat Jun ::
Last change: Sat Jun :: by root via cibadmin on node1 nodes configured
resource configured Online: [ node1 node2 ] Active resources: my_first_svc (ocf::heartbeat:Dummy): Started node1

故障验证

手动停止服务模拟故障

crm_resource --resource my_first_svc --force-stop

1min后再次查看状态,可知服务切换到了节点2

[root@node1 ~]# crm_mon -
Stack: corosync
Current DC: node1 (version 1.1.-.el7-f14e36fd43) - partition with quorum
Last updated: Sat Jun ::
Last change: Sat Jun :: by root via cibadmin on node1 nodes configured
resource configured Online: [ node1 node2 ] Active resources: my_first_svc (ocf::heartbeat:Dummy): Started node2 Failed Resource Actions:
* my_first_svc_monitor_60000 on node1 'not running' (): call=, status=complete, exitreason='No process state file found',
last-rc-change='Sat Jun 6 15:29:26 2020', queued=0ms, exec=0ms

CentOS7搭建Pacemaker高可用集群(1)的更多相关文章

  1. corosync+pacemaker高可用集群

    高可用集群,是指以减少服务中断(如因服务器宕机等引起的服务中断)时间为目的的服务器集群技术.简单的说,集群就是一组计算机,它们作为一个整体向用户提供一组网络资源.这些单个的计算机系统就是集群的节点. ...

  2. 阿里云搭建k8s高可用集群(1.17.3)

    首先准备5台centos7 ecs实例最低要求2c4G 开启SLB(私网) 这里我们采用堆叠拓扑的方式构建高可用集群,因为k8s 集群etcd采用了raft算法保证集群一致性,所以高可用必须保证至少3 ...

  3. 搭建 Kubernetes 高可用集群

    使用 3 台阿里云服务器(k8s-master0, k8s-master1, k8s-master2)作为 master 节点搭建高可用集群,负载均衡用的是阿里云 SLB ,需要注意的是由于阿里云负载 ...

  4. 基于keepalived搭建MySQL高可用集群

    MySQL的高可用方案一般有如下几种: keepalived+双主,MHA,MMM,Heartbeat+DRBD,PXC,Galera Cluster 比较常用的是keepalived+双主,MHA和 ...

  5. 基于 ZooKeeper 搭建 Spark 高可用集群

    一.集群规划 二.前置条件 三.Spark集群搭建         3.1 下载解压         3.2 配置环境变量         3.3 集群配置         3.4 安装包分发 四.启 ...

  6. Spark学习之路(七)—— 基于ZooKeeper搭建Spark高可用集群

    一.集群规划 这里搭建一个3节点的Spark集群,其中三台主机上均部署Worker服务.同时为了保证高可用,除了在hadoop001上部署主Master服务外,还在hadoop002和hadoop00 ...

  7. Spark 系列(七)—— 基于 ZooKeeper 搭建 Spark 高可用集群

    一.集群规划 这里搭建一个 3 节点的 Spark 集群,其中三台主机上均部署 Worker 服务.同时为了保证高可用,除了在 hadoop001 上部署主 Master 服务外,还在 hadoop0 ...

  8. 入门大数据---基于Zookeeper搭建Spark高可用集群

    一.集群规划 这里搭建一个 3 节点的 Spark 集群,其中三台主机上均部署 Worker 服务.同时为了保证高可用,除了在 hadoop001 上部署主 Master 服务外,还在 hadoop0 ...

  9. mysql+mycat搭建稳定高可用集群,负载均衡,主备复制,读写分离

    数据库性能优化普遍采用集群方式,oracle集群软硬件投入昂贵,今天花了一天时间搭建基于mysql的集群环境. 主要思路 简单说,实现mysql主备复制-->利用mycat实现负载均衡. 比较了 ...

随机推荐

  1. JavaWeb学习之JSP(二) JSP标签

    JSP常用标签 什么是JSP标签 JSP标签,有的地方也叫做JSP动作,在JSP中编写大量的java代码会使JSP页面显得杂乱无章,看起来非常不舒服,因此JSP提供了一些类似html的标签,通过这些标 ...

  2. python操作excel----openpyxl模块

    openpyxl模块支持.xls和.xlsx格式的excel创建,但是只支持.xlsx格式的读取操作,不支持.xls的读取(可以使用xlrd模块来读取,写入操作也可使用xlwt模块),也可使用pand ...

  3. redis python操作api

    redis单例数据库 #redis单例连接 ''' redis-server redis_diy.conf ''' import redis conn=redis.StrictRedis(host=' ...

  4. 安卓网络编程学习(1)——java原生网络编程(2)

    写在前面 该博客紧接上篇博客:https://www.cnblogs.com/wushenjiang/p/12937531.html,继续学习post请求,带参数的post和get请求以及文件上传与下 ...

  5. 安卓网络编程学习(1)——java原生网络编程(1)

    写在前面 马上要进行第二轮冲刺,考虑到自己的APP在第一轮冲刺的效果不尽人意,有很多网络方面的小BUG,这里就系统学习一下网络编程,了解来龙去脉,以便更好的对项目进行优化处理. http协议 http ...

  6. PAT-1057 Stack (树状数组 + 二分查找)

    1057. Stack Stack is one of the most fundamental data structures, which is based on the principle of ...

  7. Linux赋权chmod

    chmod -R 777 文件名/ 给文件可读.可修改.可执行权限

  8. 解释一下,@SpringBootApplication

    解释一下,@SpringBootApplication其实就是以下三个注解的总和 @Configuration: 用于定义一个配置类 @EnableAutoConfiguration :Spring ...

  9. linux 权限笔记

    权限模型 linux权限模型,指的是对文件.文件夹同的读写权限,同用户之间的权限管理模型 三种角色 user 文件.文件夹的创建者,所有人 group 一个group对应多个user,user自动具有 ...

  10. spring cloud系列教程第六篇-Eureka集群版

    spring cloud系列教程第六篇-Eureka集群版 本文主要内容: 本文来源:本文由凯哥Java(kaigejava)发布在博客园博客的.转载请注明 1:Eureka执行步骤理解 2:集群原理 ...