加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

ubuntu实现nfs开机自动挂载

(2013-03-13 13:00:13)
标签:

it

现在node1(client)要挂载node2(server)的某个目录(如/home/lee)
1.在node2安装nfs-kernel-server:sudo apt-get install nfs-kernel-server
2.在node1安装nfs-common:sudo apt-get isntall nfs-common(nfs-kernel-server已经包含这个包)
3.在node2上编辑/etc/exports,主要用来设置服务器的共享目录以及权限,如
    /home/lee node1(insecure,rw,sync,no_root_squash)
node1:node1的名字(如IP,可以man 5 exports指出:
   Machine Name Formats
       NFS clients may be specified in a number of ways:

       single host
              You  may specify a host either by an abbreviated name recognized be the resolver, the
              fully qualified domain name, an IPv4 address, or an IPv6 address. IPv6 addresses must
              not  be  inside square brackets in /etc/exports lest they be confused with character-
              class wildcard matches.

       IP networks
              You can also export directories to all hosts on an IP (sub-) network  simultaneously.
              This  is  done  by specifying an IP address and netmask pair as address/netmask where
              the netmask can be specified in  dotted-decimal  format,  or  as  a  contiguous  mask
              length.   For  example, either `/255.255.252.0' or `/22' appended to the network base
              IPv4 address results in identical subnetworks with 10 bits of  host.  IPv6  addresses
              must  use  a  contiguous  mask length and must not be inside square brackets to avoid
              confusion with character-class wildcards. Wildcard characters generally do  not  work
              on IP addresses, though they may work by accident when reverse DNS lookups fail.

       wildcards
              Machine  names  may contain the wildcard characters * and ?, or may contain character
              class lists within [square brackets].  This can be used to make the exports file more
              compact;  for  instance, *.cs.foo.edu matches all hosts in the domain cs.foo.edu.  As
              these characters also match the dots in a domain name, the given  pattern  will  also
              match all hosts within any subdomain of cs.foo.edu.

       netgroups
              NIS netgroups may be given as @group.  Only the host part of each netgroup members is
              consider in checking for membership.  Empty host parts or those containing  a  single
              dash (-) are ignored.

       anonymous
              This is specified by a single * character (not to be confused with the wildcard entry
              above) and will match all clients.

       If a client matches more than one of the specifications above, then the first match from the
       above  list order takes precedence - regardless of the order they appear on the export line.
       However, if a client matches more than one of the same type of specification (e.g. two  net‐
       groups),  then  the  first  match from the order they appear on the export line takes prece‐
       dence.
insecure/secure:secure为默认值,要求网络端口小于IPPORT_RESERVED(1024),如果存在端口映射之后,端口号大于1024时,不添加insecure字段值就会报mount.nfs: access denied by server while mounting...的错误

4.刷新配置与开启nfs
    sudo exportfs -rv ; sudo /etc/init.d/nfs-kernel-server restart
5.在node1上挂载node2的/home/lee目录到/mnt下
    sudo mount -t nfs -o nolock,tcp node2(server的名字):/home/lee /mnt/
6.为了能够在开启自动挂载 可以将上述命令:
      sudo mount -t nfs -o nolock,tcp node2(server的名字):/home/lee /mnt/
写入到/etc/rc.local

ps:在/etc/fstab下写入网络挂载的信息,经测试没能开机自动挂载。不过执行sudo mount -a 倒是能够挂载成功。
部分内容来自:

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有