我的机器 CentOS 4.4Fianl
[root@localhost n300]# uname -a
Linux localhost.localdomain 2.6.9-42.EL #1 Sat Aug 12 09:17:58 CDT 2006 i686 athlon i386 GNU/Linux
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
阅读(4563) | 评论(3) | 转发(0) |