CentOS7中使用nfs共享资源

nfs服务器:192.168.186.10

nfs客户端:192.168.186.71,192.168.186.74,192.168.186.89,192.168.186.92

需求:客户端这四台获取服务端的/home/wwwweb/ea目录

 

1:nfs客户端和服务端都要先启动rpcbind和nfs,没有安装的请自行安装。推荐使用rpm安装或者yum安装

systemctl start rpcbind
systemctl start nfs

2:设置开机启动

systemctl enable rpcbind
systemctl enable nfs

nfs服务器上操作

vim /etx/exports
/home/wwwweb/ea 192.168.186.71(rw,no_root_squash,no_all_squash,async) 192.168.186.74(rw,no_root_squash,no_all_squash,async) 192.168.186.89(rw,no_root_squash,no_all_squash,async) 192.168.186.92(rw,no_root_squash,no_all_squash,async)

如果下次修改了配置,可以重启服务来使配置生效,也可以直接执行如下命令刷新配置:

exportfs -a

 

nfs客户端上操作:

然后挂载nfs:

mount -t nfs 192.168.186.71:/home/wwwweb/ea /home/wwwweb/ea

卸载nfs和普通文件系统一样:

umount /home/wwwweb/ea 

如果需要设置开机挂载,在/etc/fstab添加一行配置即可:

192.168.186.71:/home/wwwweb/ea /home/wwwweb/ea nfs rw,tcp,intr 0 1 

然后服务端和客户端都要用enable设置nfs和rpcbind服务开机启动,然后才可以正常挂载

 

你可能感兴趣的:(CentOS7中使用nfs共享资源)