When the client mounts the NFS service, an error occurs mount.nfs: access denied by server while mounting (server denied access during installation) solution

 access denied by server while mounting (server denied access during installation) solution

The first step is to check whether the software rpcbind and nfs-utils are installed

[root@li wode]# yum info rpcbind
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
已安装的软件包
名称    :rpcbind
架构    :x86_64
版本    :0.2.0
......                  //省略部分信息
[root@li wode]# yum info nfs-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
已安装的软件包
名称    :nfs-utils
架构    :x86_64
时期       :1
版本    :1.3.0
......                  //省略部分信息

In the second part, use showmount -e to see if you can see the NFS service on the server

[root@wu opt]# showmount -e 20.0.0.15  //查看NFS共享目录
Export list for 20.0.0.15:   
/opt/wode 20.0.0.0/24  //服务器端NFS共享的目录

The third part is to check whether the NFS service on the server side is enabled, and check whether the configuration file is wrong

[root@li wode]# systemctl restart nfs    //重启NFS服务
[root@li wode]# vi /etc/exports          //查看NFS的配置文件
/opt/woede 20.0.0.0/24(rw,sync,no_root_squash)  //允许20.0.0网段的可以查看NFS共享目录
  //我的问题就出现在这里,我发布的是/opt/wode,而我的配置文件中是/opt/woede多了个e导致我客户端在挂载的时候总是出现报错。
[root@li wode]# vi /etc/exports
/opt/wode 20.0.0.0/24(rw,sync,no_root_squash)   //修改后


1、修改前挂载情况
[root@wu opt]# mount 20.0.0.16:/opt/wode /var/tade
mount.nfs: access denied by server while mounting 20.0.0.16:/opt/wode   //报错

2、修改后挂载情况
[root@wu opt]# mount 20.0.0.16:/opt/wode /var/tade
[root@wu opt]# df -Th
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        17G  5.2G   12G   31% /
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G  8.6M  1.9G    1% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sr0                iso9660   4.3G  4.3G     0  100% /mnt
/dev/sda1               xfs      1014M  143M  872M   15% /boot
tmpfs                   tmpfs     378M     0  378M    0% /run/user/0
20.0.0.16:/opt/wode     nfs4       17G 1006M   17G    6% /var/tade          //挂载成功

Other reasons for error

1. An illegal port is used, that is, a port greater than 1024 is used.

This error can be confirmed by viewing the log:
[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
 
Solution:
Modify the configuration file /etc/exports, add the insecure option, restart the nfs service, and try to mount it again.
/home/nfsshare/ *(insecure,rw,async,no_root_squash)    

2. NFS version issue

Edit the /etc/sysconfig/nfs file and find the following:

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

Finally save, restart the nfs service, and try to mount again; if it fails to mount, try adding the -o nolock parameter afterwards.

 

3. Check whether the directory mounted by the client has read and write permissions, and just add the corresponding permissions.

4. The corresponding domain name of the client machine IP is set in /etc/hosts on the nfs server, just remove it.

 

 

Guess you like

Origin blog.csdn.net/wulimingde/article/details/107786322