用pcs,gfs2,lvm2-cluster和pacemaker 搭建NFS cluster

实验中机器的IP为 10.201.86.204,10.201.86.205,共享盘 /dev/sdb 可以在两台机器上都可以看到。

1.关闭防火墙或是配置相应的防火墙端口,为了方便,我这里直接关闭防火墙,需要在两个节点执行

        systemctl stop firewalld   
        systemctl disable firewalld

2. 关闭 setLinux,需要在两个节点执行

 命令关闭 setenforce 0,本次生效,为了防止重启后失效,修改文件

 vi /etc/selinux/config

修改 SELINUX 为disabled

SELINUX=disabled

3.在每个节点安装 pcs,pacemaker和fence-agents-all RPM 包

mount /dev/cdrom /mnt 
cd /mnt/addons/HighAvailability
yum -y install corosync*    
yum -y install resource-agents*  
yum -y install pacemaker*  
rpm -ivch clufter-common-0.77.1-1.el7.noarch.rpm
rpm -ivch clufter-bin-0.77.1-1.el7.x86_64.rpm
yum -y install python-clufte*
yum -y install pcs-0.9.168-4.el7.x86_64.rpm
yum install fence-agents-all

2. 为cluster 用户hacluster设置密码,这个用户是软件包安装好,默认创建的用户。强烈建议在两台机器上使用相同的密码,需要在两个节点执行

passwd hacluster

3.开启pcsd.service,并设置开机启动,只需要在其中的一个节点执行

systemctl start pcsd.service
systemctl enable pcsd.service

4.创建 cluster 并设置开机启动,只需要在其中的一个节点执行

pcs cluster setup --start --name my_cluster  10.201.86.204 10.201.86.205 --force
pcs cluster enable --all

5.创建fence并查看,只需要在其中的一个节点执行

pcs stonith create myapc fence_apc_snmp ipaddr="zapc.my_cluster" pcmk_host_map="10.201.86.204:1;10.201.86.205:2" pcmk_host_check="static-list" pcmk_host_list="10.201.86.204,10.201.86.205" login="hacluster" passwd="hacluster"

pcs stonith show myapc

6.安装gfs2-utils 和lvm2-cluster,需要在两个节点执行

  yum install gfs2-utils
   cd /mnt/Packages
   rpm -ivch dlm-lib-4.0.7-1.el7.x86_64.rpm
   rpm -ivch dlm-devel-4.0.7-1.el7.x86_64.rpm
  cd /mnt/addons/ResilientStorage
  rpm -ivch dlm-4.0.7-1.el7.x86_64.rpm
  rpm -ivch lvm2-cluster-2.02.186-7.el7.x86_64.rpm

7.设置 全局 Pacemaker parameter no_quorum_policy 为freeze,只需要在其中的一个节点执行

 pcs property set no-quorum-policy=freeze

8.创建DLM和CLMD 资源,只需要在其中的一个节点执行

 pcs resource create dlm ocf:pacemaker:controld op monitor interval=30s on-fail=fence clone interleave=true ordered=true


 pcs resource create clvmd ocf:heartbeat:clvm op monitor interval=30s on-fail=fence  clone interleave=true ordered=true

9.修改/etc/lvm/lvm.conf 的locking_type 为3,3 is for cluster,需要在两个节点执行

 vi /etc/lvm/lvm.conf
 locking_type =3

10.关闭lvm2-lvmetad 并禁止开机启动。这个是独占的锁,当磁盘只能挂载其中的一个节点时,需要将locking_type 设置为1,并设置lvm2-lvmetad 开机启动,需要在两个节点执行

 systemctl  disable  lvm2-lvmetad

  systemctl  stop   lvm2-lvmetad

11.设置DLM 和CLVMD的启动顺序,只需要在其中的一个节点执行
 pcs constraint order start dlm-clone then clvmd-clone
 pcs constraint colocation add clvmd-clone with dlm-clone

12.创建LV,只需要在其中的一个节点执行

pvcreate /dev/sdb
vgcreate -Ay -cy vgbackup /dev/sdb
lvcreate -L2999M -n lvbackup vgbackup

13.挂载GFS2文件系统 到目录/sharefile,挂载只需要在一个节点执行,但是目录/sharefile 需要在两个节点存在

 pcs resource create fs ocf:heartbeat:Filesystem device="/dev/vgbackup/lvbackup" directory="/sharefile" fstype="gfs2" --clone

14.设置clvmd和GCFS2启动顺序,只需要在其中的一个节点执行

 pcs constraint order start clvmd-clone then fs-clone
 pcs constraint colocation add fs-clone with clvmd-clone

15.校验NFS cluster,以我们希望的方式运行

16.重启服务器时,总是在关闭pcs job,但是要好久,需要将 shutdown-lock设为true

 pcs property set shutdown-lock=true

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值