autofs挂载
基础概念总览Autofs 分为两大工作模式间接映射Indirect Map就是你第一种写法/data /etc/auto.nfs-data --timeout60直接映射Direct Map第二种写法/- /etc/auto.direct --timeout60两台服务器安装 autofsyum install autofs -y systemctl enable --now autofs1.直接映射Direct Map要直接挂载到/data /home机器 A192.168.10.10/etc/auto.master/-是 autofs固定魔法标识代表开启「直接挂载模式」不再限定某个父目录允许在子配置文件里任意指定系统绝对路径作为挂载点/data、/home、/mnt/xxx 全都可以# 本地自定义autofs直接挂载规则 /- /etc/auto.direct --timeout60 # NIS自动映射不需要NIS可以注释 auto.master配套/etc/auto.direct/data -fstypenfs,rw,tcp,soft 192.168.10.20:/data机器 B192.168.10.20/etc/auto.master/- /etc/auto.direct --timeout60 auto.master配套/etc/auto.direct/home -fstypenfs,rw,tcp,soft 192.168.10.10:/home修改完生效步骤# 重载autofs配置不需要kill进程 systemctl restart autofs # 查看加载的所有映射确认条目识别成功 automount -m2.间接映射Indirect Map/etc/auto.master 主配置行/data /etc/auto.nfs-data --timeout60子配置文件/etc/auto.nfs-data* -fstypenfs,rw,soft,tcp 192.168.10.20:/data/*通配符匹配任意进入/data/下面的子目录名称把匹配到的目录名传递到远端路径末尾最终挂载效果核心特点autofs永远不会把远端目录挂载到/data本身只会挂载在/data/子目录名层级当你执行cd /data/abcautofs 触发挂载本机 /data/abc ↔ 192.168.10.20:/data/abc关键限制你无法直接使用/data作为挂载点入口只能访问它内部的子文件夹。 如果你直接执行ls /data只会列出空目录不会触发 NFS 挂载。专门用来批量挂载多个远端目录 比如 远端服务器有 /data/disk1、/data/disk2、/data/disk3 用*通配符访问哪个子目录就自动挂载哪一个统一收纳在本机/data下。

相关新闻

最新新闻

日新闻

周新闻

月新闻