- 论坛徽章:
- 0
|
本帖最后由 chaogle 于 2012-10-31 22:35 编辑
最近测试一了一下autofs的功能:
NFS server端共享:
# showmount -e HPC_head
Export list for HPC_head:
/home *
/share *
客户端系统:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
客户端安装: autofs-5.0.1-0.rc2.143.el5_5.6
客户端配置原始文件内容:
# cat /etc/auto.master:
#
/misc /etc/auto.misc
# 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
#
#
+auto.master
===================================================================
---> 开始配置文件"/etc/auto.master", 内容如下:
/net /etc/auto.net --timeout 60
#
+auto.master
---> 开始创建编辑脚本文件"/etc/auto.net", 执行后得到内容如下:
-fstype=nfs,hard,intr,nodev,nosuid \
HPC_head:/home \
HPC_head:/share
"/etc/auto.net"的内容如下:- #!/bin/bash
- # $Id: auto.net,v 1.8 2005/04/05 13:02:09 raven Exp $
- set -- HPC_head
- key="$1"
-
- opts="-fstype=nfs,hard,intr,nodev,nosuid"
- for P in /bin /sbin /usr/bin /usr/sbin
- do
- for M in showmount kshowmount
- do
- if [ -x $P/$M ]
- then
- SMNT=$P/$M
- break
- fi
- done
- done
- [ -x $SMNT ] || exit 1
- # Newer distributions get this right
- SHOWMOUNT="$SMNT --no-headers -e $key"
- $SHOWMOUNT | LC_ALL=C sort -k 1 | \
- awk -v key="$key" -v opts="$opts" -- '
- BEGIN { ORS=""; first=1 }
- { if (first) { print opts; first=0 }; print " \\\n\t" key ":" $1 }
- END { if (!first) print "\n"; else exit 1 }
- ' | sed 's/#/\\#/g'
复制代码 ---> 启动autofs服务:
# /etc/init.d/autofs stop
# /etc/init.d/autofs start
---> 希望挂载结果:
HPC_head:/home被自动挂载到"/net/home"下
HPC_head:/share被自动挂载到"/net/share"下
但实际结果是,有时相对应,有时则出现:
"HPC_head:/home"被自动挂载到"/net/share"下
"HPC_head:/share"被自动挂载到"/net/home"下
问: 这是为什么呢?
更奇怪的是我将脚本"/etc/auto.net"输出内容- -fstype=nfs,hard,intr,nodev,nosuid \
- HPC_head:/home \
- HPC_head:/share
复制代码 以相同的明文形式替换原有脚本的内容,结果挂载失败
这里我自己的解决办法是:
不论脚本也好,直接的挂载列表清单文件也好,形式统一为- test -fstype=nfs,hard,intr,nodev,nosuid \
- /mount_point1 HPC_head:/home \
- /mount_pint2 HPC_head:/share
复制代码 即可.
另外在查看相关资料时,还有几个疑问,希望大家帮忙解答:
a.) 上面"/etc/auto.master"原始文件中"+auto.master"的作用是是么?(在man 5 autofs中没有给出解释)
b.) 在man 5 autofs中有关于"*"、"&"的使用,不知该如何使用?
c.) 另外,man 5 autofs 中关于"Replicated Server"(重复的服务主机???),是什么意思呢?该如何使用?
Replicated Server
Multiple replicated hosts, same path:
<path> host1,host2,hostn:/path/path
Multiple hosts, some with same path, some with another
<path> host1,host2:/blah host3:/some/other/path
Multiple replicated hosts, different (potentially) paths:
<path> host1:/path/pathA host2:/path/pathB
Mutliple weighted, replicated hosts same path:
<path> host1(5),host2(6),host3(1):/path/path
Multiple weighted, replicated hosts different (potentially) paths:
<path> host1(3):/path/pathA host2(5):/path/pathB
Anything else is questionable and unsupported, but these variations will also work:
<path> host1(3),host:/blah
d.) 最后再man 5 autofs中提到内部变量替换"Variable Substitution"和通过"automount -Dvariabl=value"的方式来定义变量
不知这些变量如何使用,在什么地方能用到它们呢?
Variable Substitution
The following special variables will be substituted in the key and location fields of an automounter map
if prefixed with $ as customary from shell scripts (Curly braces can be used to separate the field name):
ARCH Architecture (uname -m)
CPU Processor Type
HOST Hostname (uname -n)
OSNAME Operating System (uname -s)
OSREL Release of OS (uname -r)
OSVERS Version of OS (uname -v) |
|