pacemaker+apache

pacemaker+apache

步骤一: 安装需要的软件包

[root@localhost ~]#  yum -y install pcs pacemaker corosync fence-agents-all httpd

步骤二: 配置两台主机表,在/etc/hosts写入

[root@localhost ~]# vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.10.2 node1
10.10.10.3 node2

步骤三: 安装后默认会创建一个用户“hacluster”给他修改一个密码

[root@localhost ~]# echo '123' | passwd --stdin hacluster

步骤四: 启动 pcsd 并设置为开机自启

[root@localhost ~]# systemctl start pcsd
[root@localhost ~]# systemctl enable pcsd

步骤五: 在群集任一节点认证,建立起各个节点之间的认证关系

[root@localhost ~]# pcs cluster auth node1 node2 -u hacluster -p 123
node1: Authorized
node2: Authorized

步骤六: 创建一个名为 mycluster 的群集,其中包含 node1 和 node2 两个节点,–start 表示在群集建立完成后自动启动该群集

[root@localhost ~]# pcs cluster setup --start --name mycluster node1 node2

步骤七: 设置 Fence -Stonith

​ 当节点出现故障时,Pacemarker 会进行资源切换,把运行在故障节点上的资源切换到正常的运行节点上,以保证服务的高可用,

​ 如果节点没有相应,处于 “大多数(quorate)状态“的节点会杀掉没有响应的节点,

​ corosync 默认启用了 stonith,而当前群集没有相应的 stonith 设备,因此此默认设备不可用,可以使用以下命令查看

[root@localhost ~]# crm_verify -L -V

​ 禁用 stonith

[root@localhost ~]# pcs property set stonith-enabled=false

​ !!!高可用集群既可以使用本地磁盘来构建纯软件的镜像型集群系统,也可以使用专门的共享磁盘装置来构建大规模的共享磁盘型集群系统,充分满足客户的不同需求。
共享磁盘主要有iscsi或DBRD。本文并没有使用共享磁盘

步骤9: 配置群集 IP

​ 不管群集服务在哪运行,我们都需要一个固定的地址来提供服务,这里使用 10.10.10.10 作为群集 IP

[root@localhost ~]# pcs resource create VIP IPaddr2 ip=10.10.10.10 cidr_netmask=24 

步骤10: 配置 apache 服务

​ 自己创建一个主页文件,node1 的主页内容为 “hello1”,node2 的主页文件为 “hello2”

systemctl start httpd

可以配置优先的 Location (此配置可选),越大的值,代表越想在对应的节点上运行

# pcs constraint location WEB prefers node1=50
# pcs constraint location WEB prefers node2=45

常用命令

查看集群状态:#pcs status

查看集群当前配置:#pcs config

开机后集群自启动:#pcs cluster enable –all

启动集群:#pcs cluster start –all

查看集群资源状态:#pcs resource show

验证集群配置情况:#crm_verify -L -V

测试资源配置:#pcs resource debug-start resource

设置节点为备用状态:#pcs cluster standby node1
设置节点为在线状态:#pcs cluster unstandby node1

设置群集自启动:#pcs cluster enable --all
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑色蒲G英~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值