当前位置:   article > 正文

NFS客户端挂载nfs服务器共享目录时的报错及解决办法:mount.nfs: access denied by server while mounting_mount.nfs access denied by server

mount.nfs access denied by server

客户端挂载nfs共享目录时的报错信息:mount.nfs: access denied by server while mounting 192.168.41.191:/nfsfile

NFS服务器
1、我原来nfs配置文件exports里面的内容如下

[root@master ~]# vim /etc/exports
/nfsfile 192.168.41.*(rw,sync,root_squash)
  • 1
  • 2

2、重启rpcbind和nfs-server服务;查看了一下nfs-server服务,上面显示“Active: active (exited) ",意思是“活动:活动(已退出)”,这是正常现像,没有影响的,跟后面客户端挂载时的报错是没有关系的。

[root@master ~]# systemctl restart rpcbind
[root@master ~]# systemctl restart nfs-server
[root@master ~]# systemctl status nfs-server
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2022-03-12 05:27:14 CST; 2s ago
  Process: 9334 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
  Process: 9333 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
  Process: 9330 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
  Process: 9345 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 9343 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 9345 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

Mar 12 05:27:14 master systemd[1]: Starting NFS server and services...
Mar 12 05:27:14 master systemd[1]: Started NFS server and services.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

NFS客户端
1、使用showmount命令查询NFS服务器的远程共享信息

[root@node1 ~]# showmount -e 192.168.41.191
Export list for 192.168.41.191:
/nfsfile 192.168.41.*
  • 1
  • 2
  • 3

2、创建本地挂载目录(如已创建有,请忽略)

[root@node1 ~]# mkdir /nfsfile
  • 1

3、使用mount命令挂载nfs服务器共享目录,发现出现了报错,挂载不上(报错意思大概就是服务器拒绝访问)

[root@node1 ~]# mount -t nfs 192.168.41.191:/nfsfile /nfsfile
mount.nfs: access denied by server while mounting 192.168.41.191:/nfsfile
[root@node1 ~]# 
  • 1
  • 2
  • 3

回到NFS服务器查错,看看是什么问题
1、修改配置文件exports
就是把共享目标权限改为*(所有,全部)

[root@master ~]# vim /etc/exports
vim /etc/exports
/nfsfile *(rw,sync,root_squash)
  • 1
  • 2
  • 3

2.重启服务

[root@master ~]# systemctl restart rpcbind
[root@master ~]# systemctl restart nfs-server
  • 1
  • 2

NFS客户端
1、使用mount命令重新挂载,回车后没有返回报错信息,即是成功挂载上,可用df -h查看挂载情况

[root@node1 ~]# mount -t nfs 192.168.41.191:/nfsfile /nfsfile
[root@node1 ~]# 
  • 1
  • 2

2、使用df -h命令查看nfs挂载情况,可以看到nfs共享目录

[root@node1 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   18G  1.1G   17G   6% /
devtmpfs                 903M     0  903M   0% /dev
tmpfs                    913M     0  913M   0% /dev/shm
tmpfs                    913M  8.6M  904M   1% /run
tmpfs                    913M     0  913M   0% /sys/fs/cgroup
/dev/sda1                497M  125M  373M  25% /boot
tmpfs                    183M     0  183M   0% /run/user/0
/dev/sr0                 4.1G  4.1G     0 100% /opt/centos
//192.168.41.191/user1    18G  1.1G   17G   6% /mnt
192.168.41.191:/nfsfile   18G  1.1G   17G   6% /nfsfile
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/486642
推荐阅读
相关标签
  

闽ICP备14008679号