NFS之autofs自动挂载问题(原创)

NFS之autofs自动挂载问题


笔者在生产环境中遇到这样一个问题,使用autofs自动挂载nfs共享时,由于配置上的失误导致了生产环境中业务的短暂中断,好在及时恢复了,没有造成大的损失。

故障描述:nfs客户端使用autofs故障导致/home目录挂载的卷被卸载。

客户端/etc/auto.master的配置文件如下:

注意:笔者就是该配置中犯了第一个错误,将/home目录设置为/etc/auto.nfs的主目录。也就是说,笔者将服务器端的10.241.96.124:/home/clfx挂载至nfs客户端本地的/home/clfx目录

## autofs的主配置文件
[root@node01 home]# cat /etc/auto.master
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
#/misc	/etc/auto.misc
/home	/etc/auto.nfs
#
# NOTE: mounts done from a hosts map will be mounted with the
#	"nosuid" and "nodev" options unless the "suid" and "dev"
#	options are explicitly given.
#
/net	-hosts
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master

## auto.nfs的配置如下
[root@node01 ~]# cat /etc/auto.nfs
clfx -fstype=nfs,rw,bg,hard,rsize=32768,wsize=32768 10.241.96.124:/home/clfx


在未挂载之前,/home目录中是存在如下子目录的

[root@node01 ~]# ls /home/
admin  clfx

接下来,笔者就启动autofs自动挂载nfs共享,当挂载完成后,生产环境中该客户端服务器上/home目录下的tomcat和应用目录都不见了。且业务也无法正常访问。

此时,再次查看/home目录

## 再次查看/home目录,发现admin目录不见了。
[root@node01 ~]# ls -l /home/
total 0

## cd到挂载目录,可以进入,并且已经挂载了服务器端共享
[root@node01 ~]# cd /home/clfx
[root@node01 clfx]# ls
aaaaaa  node01.chan.com  test1.txt  test2.txt  test3.txt
[root@node01 clfx]# cd ..

## 再次查看/home,发现只有clfx,没有admin
[root@node01 home]# ls -l
total 0
drwxrwxr-x 2 root root 116 Jan 16 23:45 clfx

生产环境中,验证业务已经无法正常访问,发现了应用目录不见了,笔者这里的是admin目录,场景是一样的。

此时,笔者再次犯了第二个错误,将autofs停止了,但是停止后,admin目录还是没有出现。而生产环境中,/home目录本来就是已经挂载了/dev/mapper/lv_home这个逻辑卷的,autofs也已经将/dev/mapper/lv_home这个逻辑卷给umount了。

[root@node01 home]# systemctl stop autofs.service
[root@node01 home]# ls -l
total 0

笔者尝试将/etc/auto.master中的如下配置注释掉,重新启动autofs,发现还是没有发现admin目录

[root@node01 home]# ls -l
total 0

尝试重新启动autofs,还是没有admin目录,还是没有发现admin目录。

[root@node01 home]# systemctl restart autofs.service
[root@node01 home]# ll
total 0

尝试查看mount

[root@node01 ~]# mount |grep 'home'
/etc/auto.nfs on /home type autofs (rw,relatime,fd=-1,pgrp=38150,timeout=300,minproto=5,maxproto=5,indirect,pipe_ino=-1)

在这里,我们发现,/home目录现在挂载了/etc/auto.nfs,而这个只是一个配置文件。

解决方案:

umount掉/etc/auto.nfs

[root@node01 ~]# umount /etc/auto.nfs
[root@node01 ~]# mount|grep /home
[root@node01 ~]# 
[root@node01 ~]# ls /home/
admin  clfx
[root@node01 ~]# 

再次查看发现已经发现了admin目录。

生产环境中,即使umount掉了/etc/auto.nfs,/home目录本来就是已经挂载的/dev/mapper/lv_home则需要手动执行挂载命令了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值