1.安装NFS服务 yum install nfs-utils
2.在NFS服务器上创建NFS文件共享目录
[root@localhost ~]# mkdir /nfsfile
[root@localhost ~]# chmod -Rf 777 /nfsfile
[root@localhost ~]# echo “test NFS” >> /nfsfile/test.txt
3.NFS服务程序的配置文件为/etc/exports
格式 : 共享目录路径 允许访问NFS客户端 (共享权限参数)
vim /etc/exports
/nfsfile 192.168.0.*(rw,sync,root_squash)
注意:*号后无空格
4.启动(NFS服务进行文件共享之前,需要使用RPC(远程调用)服务将NFS服务器的IP地址和端口号等信息发送给客户端,因此还需启动rpcbind服务程序)
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl enable rpcbind //加入开机启动项
[root@localhost ~]# systemctl start nfs-server
[root@localhost ~]# systemctl enable nfs-server //加入开机启动项
[root@localhost ~]# systemctl reload nfs-server //修改/etc/exports后重新加载配置文件
客户端:
1.查看
[root@localhost ~]# showmount -e 192.168.0.5 查看挂载目录
2.磁盘挂载
[root@localhost ~]# mkdir /client_nfs
mount -t 挂载文件系统的类型 服务器ip:共享文件目录 挂载到本地系统目录
[root@localhost ~]# mount -t nfs 192.168.0.5:/nfsfile /client_nfs/
NFS磁盘卸载
umount -l /client_nfs
选项 –l 在该目录空闲后再umount。
扩展:
1)希望NFS文件共享服务一直有效,在客户端的/etc/fstab文件中写入即可
192.168.0.5:/nfsfile /clinet_nfs nfs default 0 0
autofs自动挂载(用户在使用挂载到本地的磁盘时,自动完成挂载操作.节省远程NFS服务器资源)
379

被折叠的 条评论
为什么被折叠?



