签到成功

知道了

CNDBA社区CNDBA社区

Linux autofs技术小结

2022-01-10 10:00 1078 0 原创 Linux
作者: hbhe0316

1.autofs安装

#yum install autofs –y

2.编辑文件http://www.cndba.cn/hbhe0316/article/106528

#cat /etc/auto.master | grep -i "pgmcifs"
/-      /etc/auto.pgmcifs

#cat /etc/auto.pgmcifs
/home/PGM/Server        -fstype=cifs,rw,domain=.,username=username,password=password,sec=ntlmssp,uid=2011,gid=5001,file_mode=0755,dir_mode=0755,vers=3.0 ://xx.xx.xx.xxx/Server

3.重启autofshttp://www.cndba.cn/hbhe0316/article/106528

#systemctl enable autofs.service
#systemctl restart autofs.service
  1. 针对autofs开启日志,打开autofs日志后,日志会打印到/var/log/message下。
    #vi /etc/autofs.conf
    logging = debug
    
#systemctl restart autofs.service

重启autofs生效

http://www.cndba.cn/hbhe0316/article/106528
http://www.cndba.cn/hbhe0316/article/106528

  1. 针对autofs网络抓包,enp0s8为实际的网卡名称。
    #tcpdump -i enp0s8 -w /tmp/tcpdump.cap &
    

6.重启重现时候停止脚本,脚本每隔十分钟检查一次是否重现问题,如果重现问题,则kill掉tcpdump命令。http://www.cndba.cn/hbhe0316/article/106528

#chmod +x /home/tcpdump.sh
#cat /home/tcpdump.sh
#!/bin/sh
cd /home/PGM/Server > /dev/null 2>&1
if [[ $? -ne 0 ]];then
 kill -9 `ps -ef | grep tcpdump | grep -v grep | awk -F ' ' {'print $2'}`
fi
cd /

#crontab –l
*/10 * * * * /home/tcpdump.sh

7.autofs配置timeout参数,如果TIMEOUT=0,则表示umount掉挂在目录,默认TIMEOUT=300,表示默认5分钟umount掉挂载掉。

http://www.cndba.cn/hbhe0316/article/106528
http://www.cndba.cn/hbhe0316/article/106528
http://www.cndba.cn/hbhe0316/article/106528

#cat /etc/autofs.conf | grep -w timeout | grep -v "#"
timeout = 300

该设置需要重启autofs生效。

http://www.cndba.cn/hbhe0316/article/106528
http://www.cndba.cn/hbhe0316/article/106528

#systemctl restart autofs.service

版权声明:本文为博主原创文章,未经博主允许不得转载。

Linux

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1039694次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ