出现此类错误原因大致为:
- 权限问题
- 防火墙机制问题
- 共享配置文件问题
搭建好nfs服务后,在client端进行挂载时,提示:
[root@web1 media]# mount -t nfs 192.168.0.124:/server/tools/repo /media/centos/
mount.nfs: access denied by server while mounting 192.168.0.124:/server/tools/repo
查看了一下client端是否被占用了:
[root@web1 media]# mount -t nfs 192.168.0.124:/server/tools/repo /media/centos/
mount.nfs: access denied by server while mounting 192.168.0.124:/server/tools/repo
[root@web1 media]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
发现并没有,然并卵。
接着就上server端查看/etc/exports配置文件:
[root@fenfa scripts]# cat /etc/exports
exporting 192.168.0.*:/server/tools/repo
exporting 192.168.0.*:/data
把192.168.0.24的/server/tools/repo共享给同一个网段的所有服务器,把IP格式规范为192.168.0.0/24或192.168.0.0/255.255.255.0
[root@fenfa scripts]# vim /etc/exports
[root@fenfa scripts]# exportfs -rv
exporting 192.168.0.0/24:/server/tools/repo
exporting 192.168.0.0/24:/data
[root@fenfa scripts]# showmount -e 127.0.0.1
Export list for 127.0.0.1:
/server/tools/repo 192.168.0.0/24
/data 192.168.0.0/24
我们再从client端上从新挂载:
[root@web1 media]# mount -t nfs 192.168.0.124:/server/tools/repo /media/centos/
[root@web1 media]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.8G 16G 11% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 194M 29M 155M 16% /boot
192.168.0.124:/server/tools/repo 19G 6.7G 11G 39% /media/centos
is ok!
如果卸载的时候提示: umount:/mnt:device is busy;解决方法:需要退出挂载目录再进行卸载,或者是否NFS server宕机了
[root@web1 nginx-1.6.3]# umount -t nfs 192.168.0.124:/server/tools/rep /media/centos/
umount: 192.168.0.124:/server/tools/rep: not found
umount.nfs: /media/centos: device is busy
[root@web1 nginx-1.6.3]# umount -t nfs 192.168.0.124:/server/tools/rep /media/centos/
[root@web1 nginx-1.6.3]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.9G 16G 11% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 194M 29M 155M 16% /boot
需要强制卸载:mount –lf /mnt
此命令也可以:fuser –km /mnt 不建议用