您的位置:首页 > 其它

ubuntu 使用NFS共享

2014-08-15 16:16 190 查看
系统介绍:
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:一下操作只针对上述操作系统有效,且真实测试有效


步骤一:
安装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
本文出自 “精忠报国” 博客,请务必保留此出处http://xinsir.blog.51cto.com/5038915/1540692
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: