automount - CentOS 6.5 上的 autofs 挂载问题

use*_*639 3 nfs nfs4

服务器 CentOS 6.5 和 Selinux 允许

我的 NFS 服务器在 /etc/exports 中共享

/home/unixmen/  10.0.0.0/24 (rw,sync,no_root_squash)
Run Code Online (Sandbox Code Playgroud)

客户端运行在另一台 CentOS 6.5 主机上,可以正常挂载。

当我尝试使用 autofs 进行自动挂载时,没有任何效果,谷歌搜索这个问题以找出根本原因,但没有成功。

我想知道我是否在做一些基本的错误..

请参阅 autofs 配置

~]$ cat /etc/auto.master
#/net -hosts
#+auto.master
/misc /etc/auto.misc
Run Code Online (Sandbox Code Playgroud)

~]$ cat /etc/auto.misc
unixmen -fstype=nfs 10.0.0.14:/home/unixmen
Run Code Online (Sandbox Code Playgroud)

我确实更改了日志级别以在 /etc/sysconfig/autofs 中进行调试,重新启动 autofs 和日志后说

Jun 27 17:20:00 ganeshh automount[12322]: mounted indirect on /misc with timeout 300, freq 75 seconds
Run Code Online (Sandbox Code Playgroud)

不确定这是否与安装问题有关

最近,我在日志中获取了这些数据

Jun 27 18:11:49 ganeshh automount[12322]: expire_proc: exp_proc = 3063937904 path /misc
Jun 27 18:11:49 ganeshh automount[12322]: expire_cleanup: got thid 3063937904 path /misc stat 0
Jun 27 18:11:49 ganeshh automount[12322]: expire_cleanup: sigchld: exp 3063937904 finished, switching from 2 to 1
Jun 27 18:11:49 ganeshh automount[12322]: st_ready: st_ready(): state = 2 path /misc
Run Code Online (Sandbox Code Playgroud)

最终 /misc 目录中没有挂载文件

Mad*_*ter 5

现在我们已经让它工作了(-fstype=nfs在地图中不需要,并且可能无效)您的问题暴露了对如何automount呈现给用户的误解。

这是我的主文件中的自动挂载条目

/mnt    /etc/auto.master.d/mnt
Run Code Online (Sandbox Code Playgroud)

和相应的地图

# cat /etc/auto.master.d/mnt
helvellyn       -ro,soft,intr   10.18.145.31:/var/log/httpd
bowfell         -ro,soft,intr   10.18.145.27:/var/log/httpd
Run Code Online (Sandbox Code Playgroud)

现在这是ls触发器目录上的一些输出

# ls -al /mnt
total 4
drwxr-xr-x  2 root root    0 Jun 14 10:01 .
dr-xr-xr-x 25 root root 4096 Jun 27 03:37 ..
Run Code Online (Sandbox Code Playgroud)

请注意a)目录为空,并且b)大小为 0 字节。前者让您感到困惑,后者是非法的:即使是空目录也有 4096 字节的大小。但是零是知道automount已正确读取您的地图并拥有目录的速记方式。您还可以检查df

# df -k /mnt
Filesystem             1K-blocks  Used Available Use% Mounted on
/etc/auto.master.d/mnt         0     0         0    - /mnt
Run Code Online (Sandbox Code Playgroud)

现在让我们列出目标目录,即使父目录显然是空的:

# ls -al /mnt/helvellyn
total 761548
drwxr-xr-x 2 root root      4096 Jun 23 13:21 .
drwxr-xr-x 3 root root         0 Jun 27 07:31 ..
-rw-r--r-- 1 root root         0 Jun  1 03:18 access_log
-rw-r--r-- 1 root root   7485078 May 11 03:09 access_log-20140511
-rw-r--r-- 1 root root   7052254 May 18 03:06 access_log-20140518
-rw-r--r-- 1 root root   5357900 May 25 03:28 access_log-20140525
-rw-r--r-- 1 root root    577579 May 25 16:36 access_log-20140601
[...]
Run Code Online (Sandbox Code Playgroud)

内容神奇地出现!现在让我们再次列出父级:

# ls -al /mnt
total 8
drwxr-xr-x  3 root root    0 Jun 27 07:31 .
dr-xr-xr-x 25 root root 4096 Jun 27 03:37 ..
drwxr-xr-x  2 root root 4096 Jun 23 13:21 helvellyn
Run Code Online (Sandbox Code Playgroud)

Automount 确实执行了需求驱动的安装(和卸载)。由于/mnt/helvellyn在您尝试访问它之前不会被挂载,因此在第一次访问触发 mount 之前您无法看到它

我希望你能原谅我补充说,如果你从这个答案中吸取了另一个教训,那么细节在 UNIX sysadmin 中应该是至关重要的。如果指令要求您做X,那么准确地做很重要X,而不是您认为完全等同的事情X。那个零大小的小目录应该给您一些指示,表明有时向您提供的信息很少,可以让您知道某些东西,特别是较旧的 UNIX 东西,可以正常工作。如果由于不精确而滑过那些微小的标志,UNIX 将不会给您任何其他操作,并且可能会导致混淆。