多台 CentOS 之间实现简单的文件共享

栏目: 服务器 · 发布时间: 7年前

内容简介:木有技术含量,仅为自己马克一下。这里用到了 nfs 和 rpcbind 两个组件。首先在客户端与服务端机器上都安装 nfs-utils 和 rpcbind:

作者:wiLdGoose 发布时间:2019 年 2 月 14 日 分类:技术 Technology

木有技术含量,仅为自己马克一下。

这里用到了 nfs 和 rpcbind 两个组件。首先在客户端与服务端机器上都安装 nfs-utils 和 rpcbind:

yum -y install nfs-utils rpcbind

服务端机器上若开启防火墙的话需添加对应规则或关闭防火墙。按顺序依次将 rpcbind 和 nfs 设置为自动启动:

systemctl enable rpcbind.service
systemctl enable nfs.service

在服务端机器上设置共享目录:

vim /etc/exports

在文件末尾追加:

/data/share * (rw, sync, no_root_squash)

其中:

/data/share 为共享目录路径;

* 星号代表任何人;

rw 为读写权限;

sync:数据暂存于内存中,而非直接写入磁盘;

no_root_squash:使用 root 身份时,其权限转换为匿名使用者,UID 与 GID 切换为 nobody 身份。

最后在服务端机器上按顺序依次启动相关服务:

systemctl start rpcbind.service
systemctl restart nfs.service

在客户端机器上查看服务端机器的共享目录:

showmount -e 10.10.10.10

然后在本机创建对应目录:

mkdir -p /share

进行挂载:

mount -t nfs 10.10.10.10:/data/share /share

并将上述挂载命令写入 /etc/rc.local 文件以实现自动挂载:

echo mount -t nfs 10.10.10.10:/data/share /share >> /etc/rc.local

这里不推荐直接修改 /etc/fstab 文件,以防止服务端出现问题或客户端与服务端之间网络出现问题时产生异常。

最后祝福各位今夜安全而愉快。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Shallows

The Shallows

Nicholas Carr / W. W. Norton & Company / 2011-6-6 / USD 15.95

"Is Google making us stupid?" When Nicholas Carr posed that question, in a celebrated Atlantic Monthly cover story, he tapped into a well of anxiety about how the Internet is changing us. He also crys......一起来看看 《The Shallows》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具