免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1448 | 回复: 0
打印 上一主题 下一主题

[系统管理] 关于autofs的几个问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-31 22:32 |只看该作者 |倒序浏览
本帖最后由 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"的内容如下:
  1.                 #!/bin/bash
  2.                 # $Id: auto.net,v 1.8 2005/04/05 13:02:09 raven Exp $

  3.                 set -- HPC_head
  4.                 key="$1"
  5.                
  6.                 opts="-fstype=nfs,hard,intr,nodev,nosuid"

  7.                 for P in /bin /sbin /usr/bin /usr/sbin
  8.                 do
  9.                         for M in showmount kshowmount
  10.                         do
  11.                                 if [ -x $P/$M ]
  12.                                 then
  13.                                         SMNT=$P/$M
  14.                                         break
  15.                                 fi
  16.                         done
  17.                 done

  18.                 [ -x $SMNT ] || exit 1

  19.                 # Newer distributions get this right
  20.                 SHOWMOUNT="$SMNT --no-headers -e $key"

  21.                 $SHOWMOUNT | LC_ALL=C sort -k 1 | \
  22.                         awk -v key="$key"  -v opts="$opts" -- '
  23.                         BEGIN        { ORS=""; first=1 }
  24.                                 { if (first) { print opts; first=0 }; print " \\\n\t"  key ":" $1 }
  25.                         END        { if (!first) print "\n"; else exit 1 }
  26.                         ' | 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"输出内容
  1.         -fstype=nfs,hard,intr,nodev,nosuid \
  2.                  HPC_head:/home \
  3.                  HPC_head:/share
复制代码
以相同的明文形式替换原有脚本的内容,结果挂载失败

          这里我自己的解决办法是:
              不论脚本也好,直接的挂载列表清单文件也好,形式统一为
  1.         test   -fstype=nfs,hard,intr,nodev,nosuid \
  2.                                          /mount_point1  HPC_head:/home \
  3.                                          /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)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP