ubuntu 使用NFS共享

系统介绍:

    root@master:~# cat /etc/issue
Ubuntu 12.04.1 LTS \n \l

root@master:~# uname  -a
Linux master 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
root@master:~# 
安装步骤:

       PS:一下操作只针对上述操作系统有效,且真实测试有效         

wKioL1PtwB7An64oAADEGyPML6c269.jpg

步骤一:

   安装NFS服务端

    apt-get install nfs-kernel-server

   配置共享目录(关于参数后续介绍)

   vim /etc/exports

    /opt/html *(rw,sync,no_root_squash)

   启动NFS Server

   /etc/init.d/portmap restart

   /etc/init.d/nfs-kernel-server restart

步骤二、

   客户端挂载NFS

   mount -t nfs 192.168.1.185:/opt/html /var/www/html

   查看是否挂载成功

   root@ubuntu-1:~# df -h
   文件系统                 容量  已用  可用 已用% 挂载点
   /dev/mapper/ubuntu-root  464G  8.2G  432G    2% /
   udev                     869M  4.0K  869M    1% /dev
   tmpfs                    351M  320K  351M    1% /run
   none                     5.0M     0  5.0M    0% /run/lock
   none                     878M     0  878M    0% /run/shm
   /dev/sda1                228M   25M  192M   12% /boot
   192.168.1.185:/opt/html   48G  3.2G   43G    7% /var/www/html


Ubuntu nfs 常用的参数有: 
  ro 只读访问 
  rw 读写访问 

  sync 所有数据在请求时写入共享 
  async nfs 在写入数据前可以响应请求 
  secure nfs 通过 1024 以下的安全 TCP/IP 端口发送 
  insecure nfs 通过 1024 以上的端口发送 
  wdelay 如果多个用户要写入 nfs 目录,则归组写入(默认) 
  no_wdelay 如果多个用户要写入 nfs 目录,则立即写入,当使用 async 时,
无需此设置。 
  hide 在 nfs 共享目录中不共享其子目录 
  no_hide 共享 nfs 目录的子目录 
  subtree_check 如果共享/usr/bin 之类的子目录时,强制 nfs 检查父目录
的权限(默认) 
  no_subtree_check 和上面相对,不检查父目录权限 
  all_squash 共享文件的 UID 和 GID 映射匿名用户 anonymous,适合公用目
录。 
  no_all_squash 保留共享文件的 UID 和 GID(默认) 
  root_squash root 用户的所有请求映射成如 anonymous 用户一样的权限(默
认) 
  no_root_squas root 用户具有根目录的完全管理访问权限 
  anonuid=xxx 指定 nfs 服务器/etc/passwd 文件中匿名用户的 UID 
  anongid=xxx 指定 nfs 服务器/etc/passwd 文件中匿名用户的 GID 



报错:

    

       mount: wrong fs type, bad option, bad superblock on 192.168.1.195:/opt/html,

       missing codepage or helper program, or other error

       (for several filesystems (e.g. nfs, cifs) you might

       need a /sbin/mount.<type> helper program)

       In some cases useful info is found in syslog - try

       dmesg | tail  or so

解决办法:

       apt-get install nfs-common










本文转自 xinsir999 51CTO博客,原文链接:http://blog.51cto.com/xinsir/1540692,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值