【背景】
折腾:
【已解决】在远程Ubuntu服务器中开通NFS服务供别人访问服务器上的文件
期间,对于参考文档,写了下面的配置:
121.41.120.185:/home/share/image /root/nfs_client_root/ nfs auto,noatime,nolock,bg,nfsvers=4,intr,tcp,actimeo=1800 0 0
需要搞懂fstab的格式,语法。
【折腾过程】
1.搜:
fstab 语法
man fstab
man fstab bg
man fstab nolock
参考:
linux fstab 语法 – rajaruan – 51CTO技术博客
nfs(5) – nfs, nfs – nfs fstab format and options – man 5 nfs
NFS Client Configuration Files
fstab的格式:
file_system | Is the remote server directory to be mounted. |
directory | Is the mount point on the client where the directory is attached. |
type | Is the file system type. This can be nfs2 for NFS2 mounting, nfs3 for the NFS3 protocol, and nfs and nfs3pref for mounts that attempt the NFS3 protocol, but fall back to nfs2 if the attempt fails. |
options | Is mount options (see Section 4.6.2.1 in this section). |
frequency | Is always set to zero (0) for NFS and CacheFS entries. |
pass | Is always set to zero (0) for NFS and CacheFS entries. |
其中那些参数的含义是:
defaults use default options: rw, suid, dev, exec, auto, nouser, and async.
acregmin=n The minimum time (in seconds) that the NFS client caches attributes of a regular file before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 3-second minimum. acregmax=n The maximum time (in seconds) that the NFS client caches attributes of a regular file before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 60-second maximum. acdirmin=n The minimum time (in seconds) that the NFS client caches attributes of a directory before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 30-second minimum. acdirmax=n The maximum time (in seconds) that the NFS client caches attributes of a directory before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 60-second maximum. actimeo=n Using actimeo sets all of acregmin, acregmax, acdirmin, and acdirmax to the same value. If this option is not specified, the NFS client uses the defaults for each of these options listed above.
在Unix中,每个文件都有记录上次访问文件时间(atime的),修改时间(mtime),和changed time(ctime)。atime是指每个文件被读取的时间,这个功能经常受到批评,因为这样会造成性能下降,并增加磨损。然而,一些应用程序和用户会使用到atime,因此需要指定选项,atime?noatime?(in Linux) relatime (update atime if older than mtime)?Linux内核版本是2.6.29,默认是atime;2.6.30则默认是relatime。 bg (background) Mounting is performed as a background task if the first att empt fails. The default setting is off. nfsvers=n Use an alternate RPC version number to contact the NFS daemon on the remote host. This option is useful for hosts that can run multiple NFS servers. The default value is version 2. intr If an NFS file operation has a major timeout and it is hard mounted, then allow signals to interupt the file operation and cause it to return EINTR to the calling program. The default is to not allow file operations to be interrupted. tcp Mount the NFS filesystem using the TCP protocol instead of the default UDP protocol. Many NFS servers only sup- port UDP. actimeo=n Using actimeo sets all of acregmin, acregmax, acdirmin, and acdirmax to the same value. There is no default value.
|
【总结】
上述的fstab中的配置:
121.41.120.185:/home/share/image /root/nfs_client_root/ nfs auto,noatime,nolock,bg,nfsvers=4,intr,tcp,actimeo=1800 0 0
的含义是:
- 121.41.120.185:/home/share/image
- 是目标NFS服务器的IP(或域名)和NFS共享的路径
- /root/nfs_client_root/
- 是NFS客户端要mount挂载的路径(一般挂载到/mnt下面某个路径,此处只是测试,就随便挂了)
- nfs
- 表示挂载的文件系统类型时NFS
- 各个参数的含义:
- auto:自动挂载;
- noatime:不要添加access time==上次访问文件时间;
- nolock:禁止文件加锁。有时候访问旧的NFS服务器需要此参数。
- bg:挂载作为后台服务去运行,如果第一次挂载失败了。默认是off的。
- nfsvers=4:指定NFS协议的版本。
- intr:允许NFS请求被中断,如果服务器挂了或连不上
- tcp:指定NFS(不适用默认的UDP而改用)TCP
- actimeo=1800:acregmin==acregmax==acdirmin====acdirmax,都设置为1800s=30分钟,即文件缓存时间为30分钟
- 0
- 不需要NFS的CacheFS?
- 0
- 不需要NFS的CacheFS?