NFS共享存储

实验环境:

一台共享服务器和两台web服务器

配置共享服务器:

1.安装nfs共享服务

yum -y install nfs-utils rpcbind

2.启动nfs服务

systemctl enable rpcbind

systemctl enable nfs

3.设置共享目录

mkdir -p /opt/wwwroot

vim /etc/exports

/opt/wwwroot 192.168.200.0/24(rw,sync,no_root_squash)

4.重启服务

systemctl restart rpcbind

systemctl restart nfs

5.查看共享信息

showmount -e 

配置web服务器

1.起服务

systemctl enable rpcbind

systemctl start rpcbind

2.手动挂载NFS共享目录

mount 192.168.200.114:/opt/wwwroot /var/www/html

3.查看挂载情况

tail -1 /etc/matb

4.创建测试文件

vim /var/www/html/index.html

zhelishigongxiang!

5.自动挂载设置

vim /etc/fstab

192.168.200.114:/opt/wwwroot/var/www/html nfs defaults,_netdev 0 0

原文地址:https://www.cnblogs.com/990114-jhc/p/11631809.html