默认情况下,Linux ext2/ext3 文件系统在文件被访问、创建、修改等的时候记录下了文件的一些时间戳,比如:文件创建时间、最近一次修改时间和最近一次访问时间。因为系统运行的时候要访问大量文件,如果能减少一些动作(比如减少时间戳的记录次数等)将会显著提高磁盘 IO 的效率、提升文件系统的性能。Linux 提供了noatime 这个参数来禁止记录最近一次访问时间戳。
给文件系统挂载的时候加上noatime参数能大幅提高文件系统性能。
服务器端:
[root@nfs-server~]# cat /etc/redhat-release
CentOSrelease 5.8 (Final)
[root@nfs-server~]# uname -r
2.6.18-308.el5
[root@nfs-server~]# rpm -qa nfs-utils portmap
portmap-4.0-65.2.2.1
nfs-utils-1.0.9-60.el5
[root@nfs-server~]# cat /etc/exports
/data192.168.196.0/24(rw,sync)
[root@nfs-server~]# ls -ld /data/
drwxrwxrwx2 root root 4096 Sep 15 09:42 /data/
[root@nfs-server~]#
客户端:
[root@nfs-client~]# uname -r
2.6.18-308.el5
[root@nfs-client~]# rpm -qa nfs-utils portmap
portmap-4.0-65.2.2.1
nfs-utils-1.0.9-60.el5
[root@nfs-client~]#
测试:time dd if=/dev/zero of=/pw/data/testfile bs=16kcount=16484
[root@nfs-client~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.7G 2.2G 4.1G 35% /
/dev/sda1 145M 12M 125M 9% /boot
tmpfs 249M 0 249M 0% /dev/shm
[root@nfs-client ~]# mount -t nfs192.168.196.3:/data /pw/data/
[root@nfs-client~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.7G 2.2G 4.1G 35% /
/dev/sda1 145M 12M 125M 9% /boot
tmpfs 249M 0 249M 0% /dev/shm
192.168.196.3:/data 6.7G 2.2G 4.2G 35% /pw/data
[root@nfs-client~]# mount
/dev/sda3on / type ext3 (rw)
procon /proc type proc (rw)
sysfson /sys type sysfs (rw)
devptson /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1on /boot type ext3 (rw)
tmpfson /dev/shm type tmpfs (rw)
noneon /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpcon /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.196.3:/dataon /pw/data type nfs (rw,addr=192.168.196.3)
[root@nfs-client ~]# time ddif=/dev/zero of=/pw/data/testfile bs=16k count=16484
16484+0records in
16484+0records out
270073856 bytes (270 MB) copied,13.4234 seconds, 20.1 MB/s
real 0m13.452s
user 0m0.004s
sys 0m0.533s
[root@nfs-client~]# umount /pw/data/
[root@nfs-client~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.7G 2.2G 4.1G 35% /
/dev/sda1 145M 12M 125M 9% /boot
tmpfs 249M 0 249M 0% /dev/shm
[root@nfs-client~]# mount
/dev/sda3on / type ext3 (rw)
procon /proc type proc (rw)
sysfson /sys type sysfs (rw)
devptson /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1on /boot type ext3 (rw)
tmpfson /dev/shm type tmpfs (rw)
noneon /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpcon /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@nfs-client ~]# mount -t nfs -o noatime,nodiratime192.168.196.3:/data /pw/data
[root@nfs-client~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.7G 2.2G 4.1G 35% /
/dev/sda1 145M 12M 125M 9% /boot
tmpfs 249M 0 249M 0% /dev/shm
192.168.196.3:/data 6.7G 2.5G 3.9G 39% /pw/data
[root@nfs-client~]# mount
/dev/sda3on / type ext3 (rw)
procon /proc type proc (rw)
sysfson /sys type sysfs (rw)
devptson /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1on /boot type ext3 (rw)
tmpfson /dev/shm type tmpfs (rw)
noneon /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpcon /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.196.3:/dataon /pw/data type nfs (rw,noatime,nodiratime,addr=192.168.196.3)
[root@nfs-client~]# rm /pw/data/testfile
rm:remove regular file `/pw/data/testfile'? y
[root@nfs-client ~]# time ddif=/dev/zero of=/pw/data/testfile bs=16k count=16484
16484+0records in
16484+0records out
270073856 bytes (270 MB) copied,11.7239 seconds, 23.0 MB/s
real 0m11.753s
user 0m0.004s
sys 0m0.463s
[root@nfs-client~]# rm /pw/data/testfile
rm:remove regular file `/pw/data/testfile'? y
[root@nfs-client~]#