实现NFS共享存储的WEB群集,前提是建立好web群集
这是我另一篇建立web群集的博客:
基于NFS服务器的WEB群集原理
可以根据这个图片来理解这个原理,我在web1上有照片,但是我web2没有,我可以在两台web后加一个nfs存储服务器,NFS是一个共享目录或文件的服务。web1收到的数据,在发给nfs,nfs在给web2
1、安装NFS服务器
[root@sto yum.repos.d]# yum install -y nfs-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package matching 1:nfs-utils-1.3.0-0.21.el7.x86_64 already installed. Checking for update.
Nothing to do
[root@sto yum.repos.d]# systemctl restart rpcbind
[root@sto yum.repos.d]# systemctl enable rpcbind
[root@sto yum.repos.d]# systemctl enable nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@sto yum.repos.d]# systemctl start nfs-server
[root@sto yum.repos.d]# systemctl status firewalld
[root@sto http]# systemctl stop firewalld
防火墙开启的情况要增加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
pacemaker: active/disabled
pcsd: active/enabled
[root@rs1 ~]# echo NFS > /var/www/html
[root@rs1 ~]# systemctl restart httpd
创建web集群
pcs resource create Wbsite ocf
标签:WEB,httpd,PCS,sto,NFS,nfs,root,rs1,03 From: https://blog.51cto.com/u_14519396/6000222