NFS挂载时出现mount

NFS挂载时出现"mount.nfs: access denied by server while mounting "的解决方法

1、使用了非法端口,也就是使用了大于1024的端口。
这个错误,可以通过查看日志确认:
[root@local~ /]# cat /var/log/messages | grep mount
Jan 2 12:49:04 localhost mountd[1644]: refused mount request from 192.168.0.100 for /home/nfsshare/ (/home/nfsshare): illegal port 1689

解决办法:
修改配置文件/etc/exports,加入 insecure 选项,重启nfs服务,再尝试挂载。
/home/nfsshare/  *(insecure,rw,async,no_root_squash)

/****************************

如果端口号大于1024,则需要将 insecure 选项加入到配置文件(/etc/exports)相关选项中mount客户端才能正常工作

[root@lzgonline init.d]# man exports

secure,This option requires that requests originate on an Internet port less than IPPORT_RESERVED (1024). This option is on by default. To turn it off, specify insecure.

secure 选项要求mount客户端请求源端口小于1024(然而在使用 NAT 网络地址转换时端口一般总是大于1024的),默认情况下是开启这个选项的,如果要禁止这个选项,则使用 insecure 标识

******************************/

2、NFS版本问题
编辑/etc/sysconfig/nfs文件,找到下面:

#Turn off v2 and v3 protocol support 
#RPCNFSDARGS="-N 2 -N 3" 
#Turn off v4 protocol support 
#RPCNFSDARGS="-N 4"  /*把这句前面的#号去掉*/

最后保存,重启nfs服务,再尝试挂载;如果挂载不上,可尝试在后面加-o nolock参数。我自己的如下:

[zzx@localhost ~]$ sudo mount -t nfs 192.168.1.110:/home/zzx/fl2440 /mnt/nfs -o nolock

3、查看客户端挂载的目录是否具备读写权限,添加相应权限即可。

sudo chmod 777 /mnt/nfs

4、nfs服务器上的/etc/hosts中设置了客户端机器IP对应域名,去掉即可。

img

img

posted @ 2022-11-17 22:36  xiao智  阅读(352)  评论(0编辑  收藏  举报