nfs在工作中还是需要使用的,写篇文档记录下安装过程;
参考文章:
https://blog.csdn.net/aixiaoyang168/article/details/83782336
服务端
服务端即把文件分享出来的服务器;
需要安装nfs-utils和rpcbind
yum install -y nfs-utils rpcbind
设置共享目录
/data/share
mkdir /data/share
chmod 777 /data/share
echo '/data/share *(rw,sync,insecure,no_subtree_check,no_root_squash)' >> /etc/exports
启动服务
service rpcbind start
service nfs start
参数 说明
参数 | 含义 |
---|---|
ro | 只读访问 |
rw | 读写访问 |
sync | 所有数据在请求时写入共享 |
async | nfs 在写入数据前可以响应请求 |
secure | nfs 通过 1024 以下的安全 TCP/IP 端口发送 |
insecure | nfs 通过 1024 以上的端口发送 |
wdelay | 如果多个用户要写入 nfs 目录,则归组写入(默认) |
no_wdelay | 如果多个用户要写入 nfs 目录,则立即写入,当使用 async 时,无需此设置 |
hide | 在 nfs 共享目录中不共享其子目录 |
no_hide | 共享 nfs 目录的子目录 |
subtree_check | 如果共享 /usr/bin 之类的子目录时,强制 nfs 检查父目录的权限(默认) |
no_subtree_check | 不检查父目录权限 |
all_squash | 共享文件的 UID 和 GID 映射匿名用户 anonymous,适合公用目录 |
no_all_squash | 保留共享文件的 UID 和 GID(默认) |
root_squash | root 用户的所有请求映射成如 anonymous 用户一样的权限(默认) |
no_root_squash | root 用户具有根目录的完全管理访问权限 |
anonuid=xxx | 指定 nfs 服务器 /etc/passwd 文件中匿名用户的 UID |
anongid=xxx | 指定 nfs 服务器 /etc/passwd 文件中匿名用户的 GID |
* 表示任意ip地址都能访问,也可指定范围 10.222.77.0/24
客户端
安装
需要安装nfs-utils
yum install -y nfs-utils
使用
mkdir /share
mount 服务端ip:/data/share /share