环境:
服务器:10.20.8.40 (CENTOS7.4)
客户端:172.18.243.131 (CENTOS7.4)
一、服务端
1、检查nfs服务
rpm -qa|grep nfs rpm -qa|grep rpcbind
2、启动服务
systemctl start rpcbind.service systemctl start nfs.service
3、创建共享目录
mkdir /home/swoole/haoyue_websocket/upload chmod -R 777 /home/swoole/haoyue_websocket/upload
4、配置服务端共享文件
vim /etc/exports (没有则自动创建) 加入: /home/swoole/haoyue_websocket/upload 172.18.243.131(rw,no_root_squash,async) 要加上no_root_squash,async,不然会出现reason given by server: Permission denied
5、刷新配置,立即生效
exportfs -a
重启nfs服务器:
systemctl restart nfs.service
6、查看挂载目录
#此时可用showmount -e 服务端ip来查看可mount目录 showmount -e ip
7、开机自动启动服务
chkconfig nfs on chkconfig rpcbind on
二、客户端
yum install nfs-utils 安装nfs应用
1、创建共享目录
mkdir -p /mnt/upload //创建挂载点
2、挂载目录
mount -t nfs 10.20.8.40:/home/swoole/haoyue_websocket/upload /mnt/upload
3、卸载目录
umount /mnt/upload
三、开机自动挂载
如果需要设置开机挂载,在/etc/fstab添加一行配置即可
10.20.8.40:/home/swoole/haoyue_websocket/upload /mnt/upload nfs rw,tcp,intr 0 1
showmount –e IP(查看NFS服务器上共享了那些目录) showmount –a IP(用于nfs server上,显示已经mount上本机NFS服务器的client(客户机))