1.1 安装软件:
在客户端安装
[root@localhost ~]# yum -y install nfs-utils
在服务端安装
[root@localhost ~]# yum -y install nfs-utils
1.2主机名解析:
[root@nfsclient ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.216.200 nfsclient
192.168.216.201 nfsserver
[root@nfsserver ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.216.200 nfsclient
192.168.216.201 nfsserver
1.3 创建共享目录:
[root@nfsserver ~]# mkdir /smartgoshare
1.4共享目录设置
[root@nfsserver ~]# cat /etc/exports
/smartgoshare *(rw,sync,no_root_squash)
1.5启动服务,加入开机自启动
[root@nfsserver ~]# systemctl enable nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@nfsserver ~]# systemctl start nfs-server
1.6验证
在服务端验证
[root@nfsserver ~]# showmount -e
Export list for nfsserver:
/smartgoshare *
在客户端验证
[root@nfsclient ~]# showmount -e 192.168.216.201
Export list for 192.168.216.201:
/smartgoshare *
1.7 挂载使用
root@nfsclient ~]# mount -t nfs 192.168.216.201:/smartgoshare /mnt
[root@nfsclient ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 96G 6.0G 91G 7% /
devtmpfs 975M 0 975M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 11M 981M 2% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 2.0G 164M 1.9G 9% /boot
tmpfs 199M 12K 199M 1% /run/user/42
tmpfs 199M 0 199M 0% /run/user/0
192.168.216.201:/smartgoshare 50G 5.9G 45G 12% /mnt