NFS文件系统模拟错误
server端:192.168.1.178-server-A 共享一个/tmp/serverdirA 目录属主设置为nfsnobody
client-B端:192.168.1.179-client-B 挂载在/tmp/sharedirB
client-C端:192.168.1.180-client-C 挂载在/tmp/sharedirC
###############################未连通情况下模拟错误1###############################
server端没有建立共享的目录/tmp/serverdirA
client-B端已经建立挂载的目录/tmp/serverdirB
########server端
[root@server ~]# service portmap status
portmap (pid 2244) is running...
[root@server ~]# service nfs status
rpc.mountd (pid 2362) is running...
nfsd (pid 2359 2358 2357 2356 2355 2354 2353 2352) is running...
rpc.rquotad (pid 2326) is running...
[root@server ~]# cd /tmp
[root@server tmp]# exportfs -rv
exporting 192.168.1.0/24:/tmp/serverdirA
[root@server tmp]# ls -l
total 0
[root@server tmp]#
########client-B端
[root@client-B ~]# chkconfig --list portmap
portmap 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@client-B ~]# cd /tmp/
[root@client-B tmp]# ls
sharedirB
[root@client-B tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
mount: 192.168.1.178:/tmp/serverdirA failed, reason given by server: No such file or directory ###模拟错误1###
[root@client-B tmp]#
#####解决未连通情况下模拟错误1###########
server端重新建立共享的目录/tmp/serverdirA
client-B端成功挂载目录/tmp/serverdirB
########server端
[root@server tmp]# mkdir serverdirA
[root@server tmp]# chown nfsnobody serverdirA/
########client-B端
[root@client-B tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
[root@client-B tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 21% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
192.168.1.178:/tmp/serverdirA
9.3G 1.9G 7.0G 21% /tmp/sharedirB
###############################未连通情况下模拟错误2###############################
server端没有建立共享的目录/tmp/serverdirA
client-C端没有建立挂载的目录/tmp/serverdirC
########server端
[root@server ~]# service portmap status
portmap (pid 2244) is running...
[root@server ~]# service nfs status
rpc.mountd (pid 2362) is running...
nfsd (pid 2359 2358 2357 2356 2355 2354 2353 2352) is running...
rpc.rquotad (pid 2326) is running...
[root@server ~]# cd /tmp
[root@server tmp]# exportfs -rv
exporting 192.168.1.0/24:/tmp/serverdirA
[root@server tmp]# ls -l
total 0
[root@server tmp]#
########client-C端
[root@client-C ~]# chkconfig --list portmap
portmap 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@client-C ~]# chkconfig --list nfs
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@client-C ~]# cd /tmp
[root@client-C tmp]# ls -l
total 0
[root@client-C tmp]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirA 192.168.1.0/24
[root@client-C tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirC
mount.nfs: mount point /tmp/sharedirC does not exist ###模拟错误2#####
[root@client-C tmp]#
#####解决未连通情况下模拟错误2###########
server端重新建立共享的目录/tmp/serverdirA
client-C端重新建立挂载的目录/tmp/sharedirC
[root@client-C tmp]# mkdir sharedirC
[root@client-C tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirC
[root@client-C tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 21% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
192.168.1.178:/tmp/serverdirA
9.3G 1.9G 7.0G 21% /tmp/sharedirC
[root@client-C tmp]#
###############################未连通情况下模拟错误3###############################
没有启动client-B端RPC(portmap)服务
[root@client-B tmp]# service portmap stop
Stopping portmap: [ OK ]
[root@client-B tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
###client-B端RPC(portmap)没有启动,出现等待的过程
[root@client-B tmp]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirA 192.168.1.0/24
[root@client-B tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 21% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
[root@client-B tmp]#
#####解决未连通情况下模拟错误3###########
启动client-B端RPC(portmap)服务
[root@client-B tmp]# service portmap start
Starting portmap: [ OK ]
[root@client-B tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
[root@client-B tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 21% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
192.168.1.178:/tmp/serverdirA
9.3G 1.9G 7.0G 21% /tmp/sharedirB
###############################已连通情况下模拟错误1###############################
在正常情况下,测试server端和client-B端RPC(portmap)服务随机突然挂掉
server端和client-B端RPC(portmap)服务同时挂掉还能正常的进行文件的共享
########server端
[root@server ~]# service portmap stop
Stopping portmap: [ OK ]
[root@server ~]# cd /tmp/serverdirA/
[root@server serverdirA]# touch sss
[root@server serverdirA]# ls
sss testb
[root@server serverdirA]#
########client-B端
[root@client-B sharedirB]# /etc/rc.d/init.d/portmap stop
Stopping portmap: [ OK ]
[root@client-B sharedirB]# showmount -e 192.168.1.178
###client-B端RPC(portmap)突然挂掉,server端RPC(portmap)正常
Export list for 192.168.1.178:
/tmp/serverdirA 192.168.1.0/24
[root@client-B sharedirB]# showmount -e 192.168.1.178
mount clntudp_create: RPC: Port mapper failure - RPC: Unable to receive
###server端RPC(portmap)突然挂掉,client-B端RPC(portmap)正常
[root@client-B sharedirB]#
[root@client-B sharedirB]# showmount -e 192.168.1.178
###server端RPC(portmap)突然挂掉后重新启动,client-B端RPC(portmap)正常
mount clntudp_create: RPC: Program not registered
###这个由于重新启动的portmap没有nfs注册的记录,重新启动一下nfs可以解决
###############################已连通情况下模拟错误2###############################
在正常情况下,测试server端的nfs服务挂掉
########client-B端
[root@client-B ~]# showmount -e 192.168.1.178
mount clntudp_create: RPC: Program not registered
###这个由于重新启动的portmap没有nfs注册的记录,重新启动一下nfs可以解决
[root@client-B ~]# cd /tmp/sharedirB
###server端的nfs服务挂掉,输入cd /tmp/sharedirB,client-B端出现僵死的状态,无法使用Ctrl+C退###出,server端重新启动一下nfs服务可以解决
###############################已连通情况下模拟错误3###############################
在正常情况下,测试server端的nfs服务配置文件/etc/exports原来把/tmp/serverdirA 共享给192.168.1.0/24的网段改成192.168.2.0/24
########server端
[root@server ~]# cat /etc/exports
###nfs by crazy#20151022
/tmp/serverdirA 192.168.1.0/24(rw,sync)
[root@server ~]# sed ‘s/1.0\/24/2.0\/24/g‘ /etc/exports -i
###使用sed替换命令把1.0/24网段改成2.0/24网段
[root@server ~]# cat /etc/exports
###nfs by crazy#20151022
/tmp/serverdirA 192.168.2.0/24(rw,sync)
[root@server ~]# /etc/rc.d/init.d/nfs reload
########client-B端
[root@client-B ~]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirA 192.168.2.1/24 ###server共享给192.168.2.1/24网段的目录
[root@client-B ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 21% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
192.168.1.178:/tmp/serverdirA
- - - - /tmp/sharedirB
[root@client-B ~]# umount /tmp/sharedirB
[root@client-B ~]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
mount: 192.168.1.178:/tmp/serverdirA failed, reason given by server: Permission denied
###上面一条错误提示by server: Permission denied:由于server端/tmp/serverdirA共享给192.168.2.1/24网段
###解决错误,重新配置/etc/exports文件,然后使配置文件生效即可解决
###############################已连通情况下模拟错误4###############################
在正常情况下,测试server端的nfs服务配置文件/etc/exports
########server端
[root@server ~]# vi /etc/exports
#/tmp/serverdirA/ 192.168.1.0/24(rw,sync) ##注释/tmp/serverdirA/的共享
/tmp/serverdirB/ 192.168.1.0/24(rw,sync) ##添加/tmp/serverdirB/的共享
[root@server ~]# exportfs -rv
exporting 192.168.1.0/24:/tmp/serverdirbB/
[root@server ~]# mkdir -p /tmp/serverdirB
[root@server ~]# ls -l /tmp/serverdirB/
total 0
[root@server ~]#
########client-B端
[root@client-B ~]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirB 192.168.1.0/24
[root@client-B ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 22% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
192.168.1.178:/tmp/serverdirA
- - - - /tmp/sharedirB
###由于server端/tmp/serverdirA没有共享出来
[root@client-B ~]# mount -t nfs 192.168.1.178:/tmp/serverdirB /tmp/sharedirB/
mount.nfs: Stale NFS file handle ###由于client-B端的/tmp/sharedirB/还被占用导致
[root@client-B ~]# umount /tmp/sharedirB ###client-B端的/tmp/sharedirB/取消原来的挂载
[root@client-B ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 22% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
[root@client-B ~]# mount -t nfs 192.168.1.178:/tmp/serverdirB /tmp/sharedirB/
[root@client-B ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.3G 1.9G 7.0G 22% /
/dev/sda1 190M 12M 169M 7% /boot
tmpfs 30M 0 30M 0% /dev/shm
192.168.1.178:/tmp/serverdirB
9.3G 1.9G 7.0G 22% /tmp/sharedirB
###client-B端的/tmp/sharedirB/成功挂载/tmp/serverdirB
[root@client-B ~]#
======================================================================================
总结:
server端和client端在连通后:
1.server端RPC(portmap)突然挂掉,client端RPC(portmap)正常,不影响正常的文件共享
2.client端RPC(portmap)突然挂掉,server端RPC(portmap)正常,不影响正常的文件共享
3.server端RPC(portmap)突然挂掉,client端RPC(portmap)突然挂掉,不影响正常的文件共享
4.server端nfs突然挂掉,lient-B端RPC(portmap)正常,server端可以正常访问本地的文件,client端输入#df -h命令后会出现僵死的状态,无法正常的文件共享
本文出自 “疯狂的日子” 博客,请务必保留此出处http://crazyday.blog.51cto.com/9974109/1705360
原文地址:http://crazyday.blog.51cto.com/9974109/1705360