案例——NFS实现web集群后端存储

本文介绍如何通过NFS服务实现Web集群后端共享存储。包括配置NFS服务器、挂载共享目录到Web服务器等步骤,使不同Web服务器能够访问相同内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

案例——NFS实现web集群后端存储

1、创建NFS-Server服务

[root@nfs-server share]# mkdir /share/web
[root@nfs-server share]# ls
nfs  web

[root@nfs-server share]# echo "this is the test page of nfs-web" >/share/web/index.html

[root@nfs-server share]# vim /etc/exports
   /share/web 192.168.221.0/24(ro)

[root@nfs-server share]# service nfs restart
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Shutting down RPC idmapd:                                  [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]

2、 web1端挂载NFS服务器

[root@web ~]# mount.nfs 192.168.221.129:/share/web /var/www/html/
[root@web ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/vg_min1-lv_root   13G  1.6G   11G  14% /
tmpfs                        491M     0  491M   0% /dev/shm
/dev/sda1                    485M   33M  427M   8% /boot
/dev/sr0                     4.2G  4.2G     0 100% /mnt/dvd
192.168.221.129:/share/web    13G  1.3G   11G  11% /var/www/html

[root@web ~]# cd /var/www/html/
[root@web html]# ls
index.html
[root@web html]# cat index.html 
this is the test page of nfs-web
//挂载访问成功
[root@web ~]# curl 192.168.221.139
this is the test page of nfs-web
//web访问成功

3、 web2端挂载NFS服务器

[root@web2 ~]# mount.nfs 192.168.221.129:/share/web /var/www/html/
[root@web2 ~]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/vg_min3-lv_root   13G  2.8G  9.5G  23% /
tmpfs                        491M     0  491M   0% /dev/shm
/dev/sda1                    485M   33M  427M   8% /boot
/dev/sr0                     4.2G  4.2G     0 100% /mnt/dvd
192.168.221.129:/share/web    13G  1.3G   11G  11% /var/www/html

[root@web2 ~]# cd /var/www/html/
[root@web2 html]# ls
index.html
[root@web2 html]# cat index.html 
this is the test page of nfs-web
//挂载访问成功
[root@web2 html]# curl 192.168.221.134
this is the test page of nfs-web
//web访问成功

总结:

​ 使用nfs服务将web需要访问的页面挂载到各个web中,达到访问不同web服务器,访问的内容相同的目的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值