服務(wù)端:
[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開機(jī)啟動(dòng)
[root@localhost ~]# systemctl enable nfs
nfs啟動(dòng)
[root@localhost ~]# systemctl is-active rpcbind
[root@localhost ~]# systemctl start nfs
驗(yàn)證啟動(dòng)
[root@localhost ~]# systemctl start nfs
創(chuàng)建共享目錄
[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,生效設(shè)置
[root@localhost ~]# exportfs -r
查看共享目錄
[root@localhost ~]# exportfs -v
卸載所有共享
[root@localhost ~]# exportfs -au
重掛所有
[root@localhost ~] # exportfs -ar
客戶端:
[root@localhost ~]# yum -y install nfs-utils
使用showmount命令查看遠(yuǎn)程nfs服務(wù)器共享目錄
[root@localhost ~]# showmount 192.168.200.11 -e
Export list for 192.168.200.11:
/protected (everyone)
/public (everyone)
新建掛載點(diǎn)
root@localhost ~]# mkdir /mnt/public
[root@localhost ~]# mkdir /mnt/protected
掛載NFS服務(wù)器共享目錄
[root@localhost ~]# mount -t nfs 192.168.200.11:/public /mnt/public/
[root@localhost ~]# mount -t nfs 192.168.200.11:/protected /mnt/protected/
驗(yàn)證掛載
[root@localhost ~]# mount | egrep "(public|protected)"
測試權(quán)限
[root@localhost ~]# cd /mnt/public/
[root@localhost public]# touch test
touch: cannot touch ‘test’: Read-only file system