服务端:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# ip addr
inet 192.168.200.11/24
nfs安装
[root@localhost ~]# yum -y install nfs-utils
nfs开机启动
[root@localhost ~]# systemctl enable nfs
nfs启动
[root@localhost ~]# systemctl is-active rpcbind
[root@localhost ~]# systemctl start nfs
验证启动
[root@localhost ~]# systemctl start nfs
创建共享目录
[root@localhost ~]# mkdir /public
[root@localhost ~]# mkdir /protected
通过/etc/exports文件定义共享目录
[root@localhost ~]# cat /etc/exports
/public 192.168.200.0/24 (ro)
/protected 192.168.200.0/24 (rw)
重新加载共享文件列表/etc/exports,生效设置
[root@localhost ~]# exportfs -r
查看共享目录
[root@localhost ~]# exportfs -v
卸载所有共享
[root@localhost ~]# exportfs -au
重挂所有
[root@localhost ~] # exportfs -ar
客户端:
[root@localhost ~]# yum -y install nfs-utils
使用showmount命令查看远程nfs服务器共享目录
[root@localhost ~]# showmount 192.168.200.11 -e
Export list for 192.168.200.11:
/protected (everyone)
/public (everyone)
新建挂载点
root@localhost ~]# mkdir /mnt/public
[root@localhost ~]# mkdir /mnt/protected
挂载NFS服务器共享目录
[root@localhost ~]# mount -t nfs 192.168.200.11:/public /mnt/public/
[root@localhost ~]# mount -t nfs 192.168.200.11:/protected /mnt/protected/
验证挂载
[root@localhost ~]# mount | egrep "(public|protected)"
测试权限
[root@localhost ~]# cd /mnt/public/
[root@localhost public]# touch test
touch: cannot touch ‘test’: Read-only file system