写点什么

基于 NFS 存储建立 WEB 群(PCS 工具)

作者:Java高工P7
  • 2021 年 11 月 11 日
  • 本文字数:2058 字

    阅读完需:约 7 分钟

防火墙开启的情况要增加 nfs,rpc-bind,mounted 服务,然后 reload 生效


2、准备 NFS 服务器资源


创建 Export 目录(共享目录)


[root@sto yum.repos.d]# mkdir /http


[root@sto yum.repos.d]# chmod a+x /http


[root@sto yum.repos.d]# vi /etc/exports


/http * (rw)


[root@sto yum.repos.d]# systemctl restart nfs-server


在其他节点进行测试


[root@rs1 ~]# showmount -e sto


Export list for sto:


/http *


[root@rs1 ~]# mkdir /mnt/nfs


[root@rs1 ~]# mount sto:/http /mnt/nfs


[root@rs1 ~]# cp ./anaconda-ks.cfg /mnt/nfs/test.txt


[root@rs2 ~]# showmount -e sto


Export list for sto:


/http *


[root@rs2 ~]# mkdir /mnt/nfs


[root@rs2 ~]# mount sto:/http /mnt/nfs


[root@rs2 ~]# cp ./anaconda-ks.cfg /mnt/nfs/test2.txt


[root@sto http]# ls


test2.txt test.txt


创建 NFS 集群


[root@rs1 ~]# pcs resource create WebFS ocf:heartbeat:Filesystem \


device='sto:/http' directory='/var/www/html' fstype='nfs' \


op monitor interval=20s timeout=40s \


op start timeout=60s op stop timeout=60s


[root@rs1 ~]# pcs resource create WebFS ocf:heartbeat:Filesystem device='storage:/http' directory='/var/www/html' fstype='nfs' op monitor interval=20s timeout=40s > op start timeout=60s op stop timeout=60s


[root@rs1 ~]# pcs status


Cluster name: cluster1


Stack: corosync


Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) - partition with quorum


Last updated: Sat May 9 02:59:31 2020


Last change: Sat May 9 02:59:22 2020 by root via cibadmin on rs1


2 nodes configured


3 resources configured


Online: [ rs1 rs2 ]


Full list of resources:


VirtualIP (ocf::heartbeat:IPaddr2): Started rs1


WebFS (ocf::heartbeat:Filesystem): Started rs2


Daemon Status:


corosync: active/disabled


pacem


【一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义】
浏览器打开:qq.cn.hn/FTf 免费领取
复制代码


aker: active/disabled


pcsd: active/enabled


[root@rs1 ~]# echo NFS > /var/www/html


[root@rs1 ~]# systemctl restart httpd


创建 web 集群


pcs resource create Wbsite ocf??apache


httpd="/usr/sbin/httpd" \


configfile=/etc/httpd/conf/httpd.conf \


statusurl=“http://localhost/server-status” \


op monitor interval=1min


之前碰到的问题是 web 群集起不来,后来在一篇文章发现要添加 httpd="/usr/sbin/httpd" ,也就是 httpd 命令的位置,这样就可以了


[root@rs1 html]# pcs status


Cluster name: cluster1


Stack: corosync


Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) - partition with quorum


Last updated: Sat May 9 03:41:11 2020


Last change: Sat May 9 03:21:45 2020 by root via cibadmin on rs1


2 nodes configured


3 resources configured


Online: [ rs1 rs2 ]


Full list of resources:


VirtualIP (ocf::heartbeat:IPaddr2): Started rs1


WebFS (ocf::heartbeat:Filesystem): Started rs1


Wbsite (ocf::heartbeat:apache): Started rs1


Daemon Status:


corosync: active/disabled


pacemaker: active/disabled


pcsd: active/enabled


配置组和约束


通过将资源运行在同一节点上


[root@rs1 ~]# pcs resource group add a VirtualIP WebFS Website


[root@rs1 html]# pcs status Cluster name: cluster1 Stack: corosync


Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) - partition with


quorum Last updated: Sat May 9 03:42:47 2020 Last change: Sat May 9


03:42:44 2020 by root via cibadmin on rs1



2 nodes configured 3 resources configured



Online: [ rs1 rs2 ]



Full list of resources:



Resource Group: a


VirtualIP (ocf:??IPaddr2): Started rs1


WebFS (ocf:??Filesystem): Started rs1


Wbsite (ocf:??apache): Started rs1



Daemon Status: corosync: active/disabled pacemaker:


active/disabled pcsd: active/enabled


通过约束管理资源的启动


[root@rs1 ~]# pcs constraint order VirtualIP then Website


Adding VirtualIP Wbsite (kind: Mandatory) (Options: first-action=start then-action=start)


[root@rs1 ~]# pcs constraint order WebFS then Website


Adding WebFS Wbsite (kind: Mandatory) (Options: first-action=start then-action=start)


资源在 web1 的情况下访问 VIP



资源在 web2 的情况下访问:


[root@rs1 ~]# pcs status


Cluster name: cluster1


Stack: corosync


Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) - partition with quorum


Last updated: Sat May 9 03:55:54 2020


Last change: Sat May 9 03:55:40 2020 by root via cibadmin on rs1


2 nodes configured


3 resources configured


Node rs1: standby


Online: [ rs2 ]


Full list of resources:


Resource Group: a


VirtualIP (ocf::heartbeat:IPaddr2): Started rs2


WebFS (ocf::heartbeat:Filesystem): Started rs2


Wbsite (ocf::heartbeat:apache): Starting rs2

用户头像

Java高工P7

关注

还未添加个人签名 2021.11.08 加入

还未添加个人简介

评论

发布
暂无评论
基于NFS存储建立WEB群(PCS工具)