首页 > 系统服务 > 详细

linux--nfs 网络文件共享

时间:2017-12-14 10:20:04      阅读:296      评论:0      收藏:0      [点我收藏+]
NFS

NFS,网络文件系统。一个系统在网络上与他人共享目录和文件。通过使用NFS,用户和程序可以像访问本地

文件一样访问系统上的文件。
用途:共享文件
优点:节省磁盘空间
组成:一台服务器和一台或多台客户机

1.安装、开启

技术分享图片

[root@server ~]# systemctl start nfs  

[root@server ~]# systemctl start nfs   开启服务

添加防火墙策略

 技术分享图片

列出防火墙状态

 技术分享图片

2.共享目录

[root@server ~]# mkdir /public/nfs -p   ##建立共享目录

 

[root@server ~]# mkdir /public/nfs/file ##建立共享文件

 

[root@server ~]# vim /etc/exports

 

[root@server ~]# exportfs -rv

exporting *:/public/nfs

技术分享图片

exports内容

 技术分享图片

测试

(客户端)

挂载

 技术分享图片

3.autofs(自动挂载工具)

当有需求的时候直接进入/net 就自动挂载成功

安装、开启(客户端)

[root@client ~]# yum install autofs.x86_64 -y

 

[root@client ~]# systemctl start autofs

 

查看autofs的根目录

 技术分享图片

自动挂载到/net下

 技术分享图片

[root@client nfs]# vim /etc/auto.master

永久性挂载

 技术分享图片

[root@client nfs]# vim /etc/auto.nfs

 技术分享图片

[root@client nfs]# systemctl restart autofs.service

 

4.共享目录的一些配置

给共享目录权限

服务端(117主机)中exports /public/nfs  *(sync,rw)  ##共享给所有人可读可写

[root@server ~]# vim /etc/exports

[root@server ~]# exportfs -rv            ##将刚编辑内容刷新并加载

exporting *:/public/nfs

测试(测试主机中)

 技术分享图片

服务端(117主机)中exports /public/nfs    172.25.254.0/24(sync) ##共享给172.25.254.0/24网段只读

[root@server ~]# vim /etc/exports

[root@server ~]# exportfs -rv

exporting *:/public/nfs

测试(测试主机中)

 技术分享图片

服务端(117主机)中exports /public/nfs    *(sync,no_root_squash,rw) ##共享给所有人,当客户段使用root挂载不转换用户身份

[root@server ~]# vim /etc/exports

[root@server ~]# exportfs -rv

exporting *:/public/nfs

测试(测试主机中)

 技术分享图片

 

服务端(117主机)中exports /public/nfs    *(sync,rw,anonuid=1001,anongid=1001) ##共享给uid=1001,gid=1001的用户可读写

[root@server ~]# vim /etc/exports

[root@server ~]# exportfs -rv

exporting *:/public/nfs

测试(测试主机中)

 

 技术分享图片

 


linux--nfs 网络文件共享

原文:http://blog.51cto.com/13352594/2050474

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!