中国青基会
RSS
热门关键字:  linux    None  Squid  linux moodle安装
当前位置 : Nixsky>服务器>其他服务器>列表

Linux 下NFS 的使用

来源: 作者: 时间:2007-04-05 点击:

客户端使用 NFS
1.查看 NFS 的服务:

client 要查看 Server 有提供哪些 NFS 服务,可以使用 showmount 这个指令。
# showmount -e 可看有分享哪些目录
# showmount -a 可看出所有的 mount

2.连接 NFS Server
要使用 NFS server 上的资源,使用 mount 指令就可以了。
# mount -t nfs hostname:/shared_dir

例:
# mount -t nfs 192.168.1.100:/tmp /mnt/nfs

3.开机时自动连上 NFS
如果希望开机的时候,系统就自动挂载 NSF,则需要编辑 /etc/fstab 档。
例:
192.168.1.100:/tmp /mnt/nfs nfs defaults 0 0

可能出问题的地方:
1.权限的设定不符合
2.忘记了激活portmap,此时会报错:
 mount: RPC: Port mapper failure - RPC: Unable to receive 或者
 mount: RPC: Program not registered
 那么,启动portmap,并且重新启动nfs
 #service portmap start
 #service nfs restart
3.被防火墙搞掉
 重新设置防火墙,包括iptables与TCP_Wrappers,因为激活了portmap,所以port 111必须提供出去.因此在iptables rules中,要增加:
 iptables -A INPUT -p TCP --dport 111 -j ACCEPT
 iptables -A INPUT -p UDP --dport 111 -j ACCEPT
 如果还不行,那就是TCP_Wrappers的问题,检查/etc/hosts.deny,如果有一行是:
  ALL: ALL: deny
 那就必须在/etc/hosts.allow中增加:
  portmap: ALL: allow
 如果我们的NFS针对内部网络开发,对于外部网络只对学术网络开发(140.0.0.0/8),可以:
  iptables -A INPUT -i eth0 -p TCP -s 192.168.0.0/24 --dport 111 -j ACCEPT
  iptables -A INPUT -i eth0 -p UDP -s 192.168.0.0/24 --dport 111 -j ACCEPT
  iptables -A INPUT -i eth0 -p TCP -s 140.0.0.0/8 --dport 111 -j ACCEPT
  iptables -A INPUT -i eth0 -p UDP -s 140.0.0.0/8 --dport 111 -j ACCEPT
 还可以使用TCP_Wrappers,在/etc/hosts.allow里面规定连上 NFS 主机的主机 IP 与名称,例如
 #vi /.etc/hosts.allow
 portmap: 192.168.0.0/255.255.255.0 :allow
 portmap: 140.113.23.23    :allow
 portmap: .sdu.edu.cn    :allow
 
RPC Server的相关命令
 rpcinfo
 #rpcinfo -p hostname(orIP)
要注意的问题:
  需要注意的是,由于 NFS 使用的这个RPC在 client 端连上主机时,那么你的主机想要关机,那可就会成为『不可能的任务』!我还不知道正确的原因是什么,但是,如果你的 Server 上面还有 Client 在联机,那么你要关机,可能得要等到数个钟头才能够正常的关机成功!嗄!真的假的!不相信吗?不然您自个儿试试看! ^_^!所以啰,建议您的 NFS Server 想要关机之前,能更先『关掉 portmap 与 nfs 』这两个东西!如果无法正确的将这两个 daemons 关掉,那么先以 netstat -utlp 找出 PID ,然后以 kill 将他关掉先!这样才有办法正常的关机成功喔!这个请特别特别的注意呢!
 
 在TurboLinux8.0 for AMD64 (kernel 2.4.21-4smp),mount NFS时候报错为:
  portmap: server localhost not responding, timed out
 解决办法:
  mount -t nfs -o nolock node1:/public /public
 即增加-o nolock参数,原因:
 Unfsd doesn't support NLM locking, and it's causing the lockd daemon to be started (which again requires the portmapper to be installed etc.)
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册