【服务器】
[student@server0 ~]$ sudo -i
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for student:
[root@server0 ~]# systemctl start nfs-server
[root@server0 ~]# systemctl start nfs-server ; systemctl enable nfs-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'
[root@server0 ~]# mkdir /nfsshare
[root@server0 ~]# chown nfsnobody /nfsshare
[root@server0 ~]# echo '/nfsshare desktop0(rw)' >> /etc/exports
[root@server0 ~]# exportfs -r
[root@server0 ~]# firewall-cmd --permanent --add-service=nfs
success
[root@server0 ~]# firewall-cmd --reload
success
[root@server0 ~]# showmount -e
Export list for server0.example.com:
/nfsshare desktop0.example.com
#开通一下两个服务,可以在客户端那里执行showmount -e server0来看server0上导出的目录。
[root@server0 ~]# firewall-cmd --permanent --add-service=rpc-bindsuccess
[root@server0 ~]# firewall-cmd --permanent --add-service=mountd
success
[root@server0 ~]# firewall-cmd --reload
success
【客户端】
[student@desktop0 ~]$ sudo -i
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for student:
[root@desktop0 ~]# mkdir /mnt/nfsshare
[root@desktop0 ~]# tail -1 /etc/fstab
server0:/nfsshare /mnt/nfsshare nfs defaults 0 0
[root@desktop0 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3120488 7353412 30% /
devtmpfs 927072 0 927072 0% /dev
tmpfs 942660 80 942580 1% /dev/shm
tmpfs 942660 17092 925568 2% /run
tmpfs 942660 0 942660 0% /sys/fs/cgroup
server0:/nfsshare 10473984 3144704 7329280 31% /mnt/nfsshare