NFS共享
要求在虚拟机 server0 上配置NFS服务,完成以下任务:
只读的方式共享目录 /public,只能被 example.com 域中的系统访问
可读写共享目录/protected,能被 example.com 域中的系统访问
然后在虚拟机 desktop0 上访问NFS共享目录
将 server0 的 /public 挂到本地 /mnt/nfsmount
这些文件系统在系统启动时自动挂载
对于普通NFS共享来说:
服务端需要运行系统服务 nfs-server.service
客户端不需要运行特定的系统服务
服务器和客户端都需要安装nfs-utils软件包
服务器还需要安装rpcbind依赖包
(rpcbind负责提供端口)
步骤
步骤一:在server0上发布共享目录
1)准备需要的共享的文件夹
[root@server0 ~]# mkdir /public
[root@server0 ~]# mkdir /protected
2)建立NFS共享配置
[root@server0 ~]# vim /etc/exports
/public 172.25.0.0/24(ro)
/protected 172.25.0.0/24(rw)
3)启动系统服务nfs-server,并设置开机自启动
[root@server0 ~]# systemctl restart nfs-server
[root@server0 ~]# systemctl enable nfs-server
[root@server0 ~]# systemctl restart rpcbind
[root@server0 ~]# systemctl enable rpcbind
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'
步骤二:在desktop0上挂载NFS共享目录/public
1)创建挂载点
[root@desktop0 ~]# mkdir /mnt/nfsmount
2)列出server0上提供的NFS共享资源
[root@desktop0 ~]# showmount -e server0.example.com
Export list for server0.example.com:
/protected 172.25.0.0/24
/public 172.25.0.0/24
3)配置开机自动挂载共享目录/public
[root@desktop0 ~]# vim /etc/fstab
.. ..
server0.example.com:/public /mnt/nfsmount nfs _netdev 0 0
4)测试挂载配置
[root@desktop0 ~]# mount -a
[root@desktop0 ~]# df -hT /mnt/nfsmount/
Filesystem Type Size Used Avail Use% Mounted on
server0.example.com:/public nfs4 10G 3.2G 6.8G 32% /mnt/nfsmount
总结:
服务端:
安装nfs-utils,rpcbind
修改配置文件/etc/exports
启动服务
客户端:
安装nfs-utils
mount挂载验证