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端
[[email protected] ~]# service portmap status
portmap (pid 2244) is running...
[[email protected] ~]# 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...
[[email protected] ~]# cd /tmp
[[email protected] tmp]# exportfs -rv
exporting 192.168.1.0/24:/tmp/serverdirA
[[email protected] tmp]# ls -l
total 0
[[email protected] tmp]#
########client-B端
[[email protected] ~]# chkconfig --list portmap
portmap 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] ~]# cd /tmp/
[[email protected] tmp]# ls
sharedirB
[[email protected] 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###
[[email protected] tmp]#
#####解决未连通情况下模拟错误1###########
server端重新建立共享的目录/tmp/serverdirA
client-B端成功挂载目录/tmp/serverdirB
########server端
[[email protected] tmp]# mkdir serverdirA
[[email protected] tmp]# chown nfsnobody serverdirA/
########client-B端
[[email protected] tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
[[email protected] 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端
[[email protected] ~]# service portmap status
portmap (pid 2244) is running...
[[email protected] ~]# 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...
[[email protected] ~]# cd /tmp
[[email protected] tmp]# exportfs -rv
exporting 192.168.1.0/24:/tmp/serverdirA
[[email protected] tmp]# ls -l
total 0
[[email protected] tmp]#
########client-C端
[[email protected] ~]# chkconfig --list portmap
portmap 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] ~]# chkconfig --list nfs
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[[email protected] ~]# cd /tmp
[[email protected] tmp]# ls -l
total 0
[[email protected] tmp]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirA 192.168.1.0/24
[[email protected] tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirC
mount.nfs: mount point /tmp/sharedirC does not exist ###模拟错误2#####
[[email protected] tmp]#
#####解决未连通情况下模拟错误2###########
server端重新建立共享的目录/tmp/serverdirA
client-C端重新建立挂载的目录/tmp/sharedirC
[[email protected] tmp]# mkdir sharedirC
[[email protected] tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirC
[[email protected] 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
[[email protected] tmp]#
###############################未连通情况下模拟错误3###############################
没有启动client-B端RPC(portmap)服务
[[email protected] tmp]# service portmap stop
Stopping portmap: [ OK ]
[[email protected] tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
###client-B端RPC(portmap)没有启动,出现等待的过程
[[email protected] tmp]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirA 192.168.1.0/24
[[email protected] 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
[[email protected] tmp]#
#####解决未连通情况下模拟错误3###########
启动client-B端RPC(portmap)服务
[[email protected] tmp]# service portmap start
Starting portmap: [ OK ]
[[email protected] tmp]# mount -t nfs 192.168.1.178:/tmp/serverdirA /tmp/sharedirB/
[[email protected] 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端
[[email protected] ~]# service portmap stop
Stopping portmap: [ OK ]
[[email protected] ~]# cd /tmp/serverdirA/
[[email protected] serverdirA]# touch sss
[[email protected] serverdirA]# ls
sss testb
[[email protected] serverdirA]#
########client-B端
[[email protected] sharedirB]# /etc/rc.d/init.d/portmap stop
Stopping portmap: [ OK ]
[[email protected] 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
[[email protected] 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)正常
[[email protected] sharedirB]#
[[email protected] 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端
[[email protected] ~]# showmount -e 192.168.1.178
mount clntudp_create: RPC: Program not registered
###这个由于重新启动的portmap没有nfs注册的记录,重新启动一下nfs可以解决
[[email protected] ~]# 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端
[[email protected] ~]# cat /etc/exports
###nfs by crazy#20151022
/tmp/serverdirA 192.168.1.0/24(rw,sync)
[[email protected] ~]# sed ‘s/1.0\/24/2.0\/24/g‘ /etc/exports -i
###使用sed替换命令把1.0/24网段改成2.0/24网段
[[email protected] ~]# cat /etc/exports
###nfs by crazy#20151022
/tmp/serverdirA 192.168.2.0/24(rw,sync)
[[email protected] ~]# /etc/rc.d/init.d/nfs reload
########client-B端
[[email protected] ~]# 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网段的目录
[[email protected] ~]# 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
[[email protected] ~]# umount /tmp/sharedirB
[[email protected] ~]# 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端
[[email protected] ~]# 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/的共享
[[email protected] ~]# exportfs -rv
exporting 192.168.1.0/24:/tmp/serverdirbB/
[[email protected] ~]# mkdir -p /tmp/serverdirB
[[email protected] ~]# ls -l /tmp/serverdirB/
total 0
[[email protected] ~]#
########client-B端
[[email protected] ~]# showmount -e 192.168.1.178
Export list for 192.168.1.178:
/tmp/serverdirB 192.168.1.0/24
[[email protected] ~]# 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没有共享出来
[[email protected] ~]# mount -t nfs 192.168.1.178:/tmp/serverdirB /tmp/sharedirB/
mount.nfs: Stale NFS file handle ###由于client-B端的/tmp/sharedirB/还被占用导致
[[email protected] ~]# umount /tmp/sharedirB ###client-B端的/tmp/sharedirB/取消原来的挂载
[[email protected] ~]# 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
[[email protected] ~]# mount -t nfs 192.168.1.178:/tmp/serverdirB /tmp/sharedirB/
[[email protected] ~]# 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
[[email protected] ~]#
======================================================================================
总结:
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命令后会出现僵死的状态,无法正常的文件共享