Chinaunix首页 | 论坛 | 博客
  • 博客访问: 783629
  • 博文数量: 108
  • 博客积分: 2887
  • 博客等级: 少校
  • 技术积分: 1570
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-28 07:51
文章分类

全部博文(108)

文章存档

2012年(4)

2011年(86)

2010年(18)

分类: LINUX

2010-12-25 18:13:40

  今天,在不断的尝试之下终于搞定了nfs利用autofs自动挂载的问题
方法:我的nfs服务器搭建在192.168.200.159上面,client端为192.168.200.162
 
  首先,分别在server端和client端开启nfs服务,具体的方法不说
  
  接下来在client端设置自动挂载的配置文件。

  编辑/etc/auto.maser,在文件的最后加入想要的挂载点的上一层目录具体以我的为例

 
  2 # $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
  3 #
  4 # Sample auto.master file
  5 # This is an automounter map and it has the following format
  6 # key [ -mount-options-separated-by-comma ] location
  7 # For details of the format look at autofs(5).
  8 #
  9 /misc   /etc/auto.misc
 10 #
 11 # NOTE: mounts done from a hosts map will be mounted with the
 12 #   "nosuid" and "nodev" options unless the "suid" and "dev"
 13 #   options are explicitly given.
 14 #
 15 /net    -hosts
 16 #
 17 # Include central master map if it can be found using
 18 # nsswitch sources.
 19 #
 20 # Note that if there are entries for /net or /misc (as
 21 # above) in the included master map any keys that are the
 22 # same will not be seen as the first read key seen takes
 23 # precedence.
 24 #
 25 +auto.master
 26 /home/public /etc/auto.nfs  

添加最后一行,表示我将要把nfs共享的一些目录挂载在/home/public下面,这些要挂载的目录不需要预先在/home/public下面建立,autofs会在我们需要的时候自动的建立并挂载相应的目录, 后面的
/etc/auto.nfs表示使用的配置文件,文件的名称可以自己取,该文件预先在/etc下面是不存在的,需要自己建立,该文件的内容为:
 [本地的目录][-挂载的参数][服务器所共享的目录]
本地的目录:指的是刚刚我们在/etc/auto.master最后一行添加的/home/public的下一层目录
挂载的参数:可有可无,指的是mount命令的参数,还有nfs使用的热书的参数
[服务器端共享的目录]:nfs主机上共享出来的目录,例如我的是192.168.200.159:/home/public

下面建立/ect/auto.nfs
   {~~}#vi /etc/auto.nfs
pub 192.168.200.159:/home/public
#表示autofs服务将在我需要的时候将192.168.200.159这个nfs服务共享出来的/home/public目录挂载到client(我的client为:192.168.200.162)端的/home/public/pub下面

接下来启动autofs服务就可以自动在我们需要的时候挂载共享目录了,在默认的5分钟内不使用挂载的目录,就自动的卸载,在我们再一次的需要时在重新的挂载上来
[~~]#/etc/init.d/autofs start

我们下载可以[~~]#cd /homg/public/pub; ls
就可以看到共享的资料了

下面说一下我遇到的问题:
   在client端我正确设置好相应的配置文件以后,启动autofs服务,我把工作目录cd到/home/public下面,使用ls命令没有看到共享的目录,但是我可以确定我已经正确的设置了相关的配置文件,后来尝试了很多的方法,终于让我找到原因了:
   在我启动autofs服务之后,我的client的确已经可以正确的自动挂载共享目录了,可是我为什么在client端/home/public下面看不到相应的共享目录呢? 因为我还没有只用共享的目录,所以autofs服务就没有挂载,使用cd /homg/public/pub命令就代表我使用了共享的目录,autofs服务就自动在我的client端的/home/public下面建立pub目录,并挂载,所以我是用ls命令就看到了nfs主机共享出来的目录了。。。。
阅读(6020) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

一首动情的歌2012-12-20 22:18:46

在client端我正确设置好相应的配置文件以后,启动autofs服务,我把工作目录cd到/home/public下面,使用ls命令没有看到共享的目录啊。。。怎么回事去兄弟。。。求指导啊。。