问题描述:


之前做过一些nfs挂载的测试,证明挂载是没问题的。


网络环境:

服务器:10.210.1.145(默认网关10.210.1.129

客户端:10.110.3.49(默认网关10.110.3.1

配置文件:

/etc/fstab

10.210.1.145:/appBackup/applogbk/10.110.3.49           /appBackup/applogbk/10.110.3.49         nfs    defaults   0 0

 

开机后nfs手工挂载没问题(mount /appBackup/applogbk/10.110.3.49

 

但在开机时,报:

Mounting NFS filesystems: mount: mount to NFS Server "10.210.1.145" failed: System Error: No route to host.


开机后nfs手工挂载没问题(mount /appBackup/applogbk/10.110.3.49

 

问题诊断:


由于linux开机读取文件的顺序:

1、加载BIOS——》2、读取MBR——》3、Boot Loader——》4、加载内核——》5、用户层init依据inittab文件来设定运行等级——》6、init进程执行rc.sysinit——》7、启动内核模块——》8、执行不同运行级别的脚本程序——》9、执行/etc/rc.d/rc.local——》10、执行/bin/login程序,进入登录状态


而第6步主要任务:

激活udev和selinux;

在/etc/sysctl.conf中设定内核参数;

设定系统时钟;

装卸按键设置;

启用交换分区;

设置主机名;

检查并重新挂载根文件系统;

激活RAID和LVM设备;

启用磁盘配额;

检查并挂载其它文件系统;

清理过时的锁和PID文件。


而第8步主要任务:

运行/etc/rc.d/rcX.d脚本,其中就有关network启动的脚本。


由此判断


系统按顺序启动,在读取/etc/fstab自动挂载信息时,网络尚未启动,所以出现上述报错信息。


解决方法:

/etc/fstab配置文件加了两个参数:soft、intr

并且soft和intr的顺序不能变,这样可以使数据损坏的可能性降低。

如下所示

10.210.1.145:/appBackup/applogbk/10.110.3.49  /appBackup/applogbk/10.110.3.49   nfs    defaults,soft,intr   0 0

soft参数含义为:如果一个NFS文件操作报错,有重大超时后,调用程序返回一个错误!      默认配置是继续重试NFS文件,并且一直等待。

intr参数含义为:允许网络中断,默认是不允许网络中断。


通过man nfs可知:


soft / hard

Determines the recovery behavior of the NFS client after an NFS request times out. If neither option is specified (or if the hard option is specified), NFS requests are retried indefinitely. If the soft option is specified, then the NFS client fails an NFS request after retrans retransmissions have been sent, causing the NFS client to return an error to the calling application.

NB: A so-called "soft" timeout can cause silent data corruption in certain cases. As such, use the soft option only when client responsiveness is more important than data integrity. Using NFS over TCP or increasing the value of the retrans option may mitigate some of the risks of using the soft option.


intr / nointr

Selects whether to allow signals to interrupt file operations on this mount point. If neither option is specified (or if nointr is specified), signals do not interrupt NFS file operations. If intr is specified, system calls return EINTR if an in-progress NFS operation is interrupted by a signal.