当前位置:蜗牛素材网>综合资讯>科技>正文

nfs自动挂载目录 挂载nfs文件系统

人气:241 ℃/2023-10-24 16:40:58

前面讲了

但很多情况我们并不需要使用共享文件系统。 例如备份,我们知道本地保存是不稳妥的,一旦硬盘故障,数据和备份都会丢失,一般情况是要求异地保存,也就是将备份放到其他的地方或主机上, 这时本地主机只要能够挂载其他主机的目录并读写就可以了。

这种情况可以使用nfs, CIFS 共享给本机挂载。 SSHFS是这些协议的备选方案

今天来分享一下如何挂载 NFS

日期: 2023-05-23

1 测试环境说明

windows 2019: 192.168.55.169 提供 nfs 存储空间 win_nfs

almaliux 9.2: 192.168.55.156 提供 nfs 存储空间 linux_nfs

oracle linux 7.9 :192.168.55.144/185 客户端 ,挂载

windows 11: 192.168.55.146 客户端 挂载

2 安装设置 nfs 服务端

2.1 windows 设置 nfs

服务管理器 ->添加角色和功能 -> 服务器角色 -> 展开 "文件和存储服务" -> 展开 "文件和 iSCSI 服务" -> 选择 "文件服务器" 和 "NFS 服务器" -> 下一步 -> 安装

新建文件夹 win_nfs, 右键点击 win_nfs -> 属性 -> NFS共享 -> 选择"共享此文件夹" 选择"不要服务器验证" "允许未匹配用户访问" "允许未匹配用户unix访问(by UID/GID)" 其他默认 -> 权限 添加 客户端ip 默认为读写

2.2 linux 配置 nfs

#NFS启动时会随机启动多个端口并向RPC注册.如果要开启防火墙,就要固定NFS端口并加入白名单。此处为方便关闭防火墙systemctl stop firewalld #关闭selinuxsed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config ; sed -i "s/SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/configsetenforce 0#安装必须的软件包yum -y install nfs-utilssystemctl restart rpcbind ; systemctl enable nfs-server --now#配置nfs服务mkdir /linux_nfschown nobody:nobody /linux_nfs #linux 8 使用 nobody, linux 7 及之前是nfsnobody , chown nfsnobody:nfsnobody /u01/backupcat > /etc/exports <<EOF/linux_nfs 192.168.55.144(rw,sync,all_squash)/linux_nfs 192.168.55.185(rw,sync,all_squash)/linux_nfs 192.168.55.146(rw,sync,all_squash)EOFsystemctl restart nfs-server3 linux 客户端挂载

3.1 linux 客户端安装

yum -y install nfs-utils

3.2 linux 客户端挂载 win_nfs

showmount -e 192.168.55.169 #列出远程共享的目录mkdir /local_win_nfsmount -t nfs 192.168.55.169:win_nfs /local_win_nfs#自动挂载 /etc/fstab 加入后, 重启可以生效, 但手动 mount -a 可以挂载但提示 "fuse: mountpoint is not empty" 未找到解决方法192.168.55.169:win_nfs /local_win_nfs nfs defaults 0 0

3.3 linux 客户端挂载 linux_nfs

showmount -e 192.168.55.156mkdir /local_linux_nfsmount -t nfs 192.168.55.156:linux_nfs /local_linux_nfs#自动挂载 /etc/fstab 加入后, 重启可以生效, 但手动 mount -a 可以挂载但提示 "fuse: mountpoint is not empty" 未找到解决方法192.168.55.156:linux_nfs /local_linux_nfs nfs defaults 0 04 windows 客户端挂载

4.1 安装

打开或关闭windows特性, 安装 Service for NFS -> Administrative Tools 和 Client for NFS

4.2 windows 客户端挂载 win_nfs

mount \\192.168.55.169\win_nfs w:

4.3 windows 客户端挂载 linux_nfs

mount \\192.168.55.156\linux_nfs l:说明

这种挂载类似于nfs的网络共享, 并不是共享文件系统。 多个节点同时挂载,写入同一个文件,会发生覆盖现象

如果要使用共享文件系统,例如 OCFS2, GFS2 ,GPFS 请参考我以前的文章。

关注防丢失。

搜索更多有关“nfs自动挂载目录 挂载nfs文件系统”的信息 [百度搜索] [SoGou搜索] [头条搜索] [360搜索]
本网站部分内容、图文来自于网络,如有侵犯您的合法权益,请及时与我们联系,我们将第一时间安排核实及删除!
CopyRight © 2008-2024 蜗牛素材网 All Rights Reserved. 手机版