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. 2018-06-24 js BOM对象

    BOM对象: Browser Object Model 即浏览器对象模型: 包含: window:窗口对象 alert();//警示框 confirm();//确认框 prompt();//输入提示框 ...

  2. shell脚本常用命令汇总

    一.shell脚本概述和入门 (1)shell脚本是一个命令行解释器,它接收应用程序/用户命令,然后调用操作系统内核 (2)shell脚本的常用执行方式: 第一种:采用bash或sh+脚本的相对路径或 ...

  3. Docker 镜像制作教程:针对不同语言的精简策略

    本系列文章将分为三个部分: 第一部分着重介绍多阶段构建(multi-stage builds),因为这是镜像精简之路至关重要的一环.在这部分内容中,我会解释静态链接和动态链接的区别,它们对镜像带来的影 ...

  4. vue element-ui el-form-item 循环渲染,验证表单内容

    data里面如下图:

  5. 全网最全Docker命令详解

    由于最近在学习Docker,在这里把有关Docker的命令做一个集合,方便后面查看: # docker --help Usage: docker [OPTIONS] COMMAND [arg...] ...

  6. js中的小案例(一)

    效果图: html代码: <div id="date"> <p> <span id="prev">上一月</span& ...

  7. 「雕爷学编程」Arduino动手做(20)—水银开关模块

    37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里 ...

  8. day07:集合的使用0220

    list_1=set([4,5,6,7])list_2=set([4,8,9])list_3=set([4,5])list_4=set([6,7])a = (2,3)b = (2) #list_3是l ...

  9. easyui API

    http://www.jeasyuicn.com/api/docTtml/index.htm

  10. Ubuntu 安装 rabbitmq

    第一步:安装 erlang 官网:https://www.erlang-solutions.com/resources/download.html 然后在终端输入:erl 显示如下,说明安装成功! E ...