autofs的作用其实和NFS差异不大,关键点在于实现自动挂载
1、为确保无干扰项需要提前关闭iptables
# 关闭iptables
iptables -F
2、server端操作
# server端
# 安装nfs与autofs服务
yum -y install nfs-utils
# 修改nfs服务配置文件
vim /etc/exports
# 加入下面行后,保存退出
/nfs_path *(rw,sync,no_root_squah)
# 刷新配置文件
exportfs -a
# 创建目录与创建文件,验证时使用
mkdir -p /nfs_path/aaa
touch /nfs_path/aaa/1.txt
# 重启nfs服务
systemctl restart nfs
3、client端操作
# client端
# 安装nfs与autofs服务
yum -y install nfs-utils autofs
# 启动nfs服务
systemctl start nfs
# 查看nfs服务的server配置是否正常
showmount -e [server端ip]
# 修改autofs配置文件(本次实现使用直接挂载的方式)
vim /etc/auto.matser
/- /etc/nfs_path.rule
# 修改间接配置文件
vim /etc/nfs_path.rule
/nfs_path/aaa -fstype=nfs,rw [server端ip]:/nfs_path/aaa
# 重启autofs服务
systemctl restart autofs
# 验证成果,查看目录已经有了server端中的1.txt文件
ll /nfs_path/aaa
参考链接: