前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux——NFS

Linux——NFS

作者头像
羊羽shine
发布2019-05-28 13:34:30
4.9K0
发布2019-05-28 13:34:30
举报
文章被收录于专栏:Golang开发Golang开发

nfs网络文件系统常用于共享音视频,图片等静态资源。将需要共享的资源放到NFS里的共享目录,通过服务器挂载实现访问。 安装

yum -y install nfs-utils rpcbind

设置开机自启动

systemctl enable nfs
systemctl enable rpcbind

创建共享目录

mkdir -p /opt/nfs

vi /etc/exports

/opt/nfs 192.168.1.0/24(rw,sync,no_root_squash)

启动nfs服务

[root@centos7 ~]# service rpcbind start
Redirecting to /bin/systemctl start rpcbind.service
[root@centos7 ~]# service nfs start
Redirecting to /bin/systemctl start nfs.service

其他服务器安装

yum -y install nfs-utils rpcbind
systemctl start rpcbind
systemctl start nfs
$ showmount -e 192.168.1.111
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)

centos7 需要关闭防火墙

sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service

再次查看

showmount -e 192.168.1.111
Export list for 192.168.1.111:
/opt/nfs 192.168.1.0/24

挂载nfs

[root@localhost ~]# mkdir /var/www
[root@localhost ~]# mount 192.168.1.111:/opt/nfs /var/www/
[root@localhost www]#echo "hello world" > /var/www/index.html

登录192.168.1.111服务器查看

$ cat /opt/nfs/index.html
hello world

磁盘被手动挂载之后都必须把挂载信息写入/etc/fstab这个文件中,否则下次开机启动时仍然需要重新挂载。 系统开机时会主动读取/etc/fstab这个文件中的内容,根据文件里面的配置挂载磁盘。这样我们只需要将磁盘的挂载信息写入这个文件中我们就不需要每次开机启动之后手动进行挂载了。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.02.21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档