主题 : Linux NFS服务器无法mount的原因 复制链接 | 浏览器收藏 | 打印
保护自己的梦想
级别: 新手上路
UID: 7883
精华: 1
发帖: 22
金钱: 250 两
威望: 240 点
综合积分: 64 分
注册时间: 2009-08-01
最后登录: 2009-11-02
楼主  发表于: 2009-08-20 18:55

 Linux NFS服务器无法mount的原因

from:::
">[url]http://blog.chinaunix.net/u1/51980/showart_679640.html <BR>[/url]
----------------------------------------------------------------------------------

1:首先确保自己已经安装有nfs服务,测试方式可以为:
#service nfs status
没有unrecognized service之类的错误输出就表示已经安装

2:编辑配置文件/etc/exports,内容简单的可以为:
/home *(rw)

也可以配置更多的参数,如
/home/work 192.168.0.*(rw,sync,no_root_squash)
添加的内容表示:允许ip 地址范围在192.168.0.*的计算机以读写的权限来访问/home/work 目录。
/home也称为服务器输出共享目录。

括号内的参数意义描述如下:
rw:读/写权限,只读权限的参数为ro;
sync:数据同步写入内存和硬盘,也可以使用async,此时数据会先暂存于内存中,而不立即写入硬盘。
no_root_squash:NFS 服务器共享目录用户的属性,如果用户是 root,那么对于这个共享目录来说就具有 root 的权限。

3:重启或者启动对应的两个服务:
[root@localhost n300]# service portmap restart
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
[root@localhost n300]# service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@localhost n300]#
4:本机测试或者其他客户端的测试:
>: mount -o nolock 10.78.28.103:/usr/n300 /mnt
mount: RPC: Unable to receive; errno = No route to host
mount: nfsmount failed: Bad file descriptor
mount: Mounting 10.78.28.103:/usr/n300 on /mnt failed: Bad file descriptor

如果有上面类似错误,有可能是如下原因
a:先ping客户端能否连通服务器ip
RPC: Unable to receive; errno = No route to host 的原因
b:nfs服务器是否有防火墙屏蔽了对应端口
c:/etc/hosts.deny /etc/hosts.allow 是否屏蔽了客户端ip

Bad file descriptor的原因
d:/etc/exports配置有问题,确保文件中的"()"是英文的,如果你从其他地方copy有可能出现如上问题

解决办法:
[root@localhost n300]# service iptables stop
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
[root@localhost n300]# service iptables status
Firewall is stopped.
[root@localhost n300]# cat /etc/hosts
hosts hosts.allow hosts.deny
[root@localhost n300]# cat /etc/hosts.deny
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!

[root@localhost n300]# cat /etc/hosts.allow
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
[root@localhost n300]#


5: 解决上面问题后应该可以正确的mount了
>: mount -o nolock 10.78.28.103:/usr /mnt
mount: 10.78.28.103:/usr failed, reason given by server: Permission denied #还是有错,iptable在作怪
mount: nfsmount failed: Bad file descriptor
mount: Mounting 10.78.28.103:/usr on /mnt failed: Bad file descriptor
>:
>:
>:####自给解决上面的错误
>:
>: mount -o nolock 10.78.28.103:/usr/n300 /mnt ##正确了
>:
>:
>: df
Filesystem Size Used Available Use% Mounted on
/dev/root 6.6M 6.6M 0 100% /
/dev/mtdblock/5 1.0M 68.0k 956.0k 7% /info
/dev/mtdblock/6 42.0M 3.3M 38.7M 8% /apps
/dev/mtdblock/7 5.0M 196.0k 4.8M 4% /logs
10.78.28.218:/home/webserver 8.4G 7.2G 780.8M 90% /tmp/mnt
10.78.28.103:/usr/n300 9.6G 6.7G 2.4G 73% /mnt



有梦想就要去追逐,只管风雨兼程!!
http://hi.baidu.com/kissky2009/blog
保护自己的梦想
级别: 新手上路
UID: 7883
精华: 1
发帖: 22
金钱: 250 两
威望: 240 点
综合积分: 64 分
注册时间: 2009-08-01
最后登录: 2009-11-02
1楼  发表于: 2009-08-20 19:10
自己顶一下
有梦想就要去追逐,只管风雨兼程!!
http://hi.baidu.com/kissky2009/blog
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
2楼  发表于: 2009-08-21 10:22
别人的东西始终是别人的,把它变成自己的才有价值。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
保护自己的梦想
级别: 新手上路
UID: 7883
精华: 1
发帖: 22
金钱: 250 两
威望: 240 点
综合积分: 64 分
注册时间: 2009-08-01
最后登录: 2009-11-02
3楼  发表于: 2009-08-21 10:46
谢谢BZ指教,说的很对,虚心接受
有梦想就要去追逐,只管风雨兼程!!
http://hi.baidu.com/kissky2009/blog