网上搜集的xfs文件系统优化方案,自己做个小结。
先贴出优化前后的对比,只是简单的用dd命令测试了一下而已,不怎么专业。写和读的文件为内存2倍。
优化前:
#写性能
[root@sapling ~]# dd if=/dev/zero of=/data/test bs=8M count=1000
1000+0 records in
1000+0 records out
8388608000 bytes (8.4 GB) copied, 172.835 seconds, 48.5 MB/s
#读性能
[root@sapling ~]# dd if=/data/test of=/dev/null bs=8M count=1000
1000+0 records in
1000+0 records out
8388608000 bytes (8.4 GB) copied, 89.7978 seconds, 93.4 MB/s
优化后:
#写性能
[root@sapling ~]# dd if=/dev/zero of=/DaTa/test bs=8M count=1000
1000+0 records in
1000+0 records out
8388608000 bytes (8.4 GB) copied, 70.1252 seconds, 120 MB/s
#读性能
[root@sapling ~]# dd if=/DaTa/test of=/dev/null bs=8M count=1000
1000+0 records in
1000+0 records out
8388608000 bytes (8.4 GB) copied, 47.0801 seconds, 178 MB/s
先是格式化xfs分区mkfs.xfs的参数(你也可以只设置-i size=512,其他会根据分区大小自动选择):
mkfs.xfs -f -i size=512 -l size=128m,lazy-count=1 -d agcount=16 /dev/sdb1
-i size=512 : 默认的值是256KB,这里的设置是为了selinux的,这个设置针对inode size,selinux使用xfs的Extend Attribute,首先要写到inode中,如果容量不够(默认是256KB的时候就不够,刚刚多一点点),就写到block中,这会损失性能,当需要使用selinux的时候。这似乎对一般用户没什么作用,因为一般用户都不用selinux的,大家对linux系统的安全性还是挺信任的,不过,说实话,我不信任,况且RedHat 的FC已经默认配置了selinux,这很好。做了这个改动,方便以后我在系统中配置selinux而不担心性能的损失。
-l size=128m :注意是小写的m,不是大写的。默认值的是10m(bsize=4096 x blocks=2560)。这个值可以设置成32m(分区容量不小于250M)/64m(分区容量不小于500M)/128m(分区容量不小于700M),对于分区容量的限制,我这里列出的只是大概,最大可设128m。修改这个参数成128m,可以显著的提高xfs文件系统删除文件的速度,当然还有其它,如拷贝文件的速度。 这个参数需要大内存的支持,内存太少的机器大概不能设置这么高。(标准是什么?512M?1G?我不了解,所以我上面说要自己实际的测试一下。)
-l lazy-count=value
This changes the method of logging various persistent counters in the superblock. Under metadata intensive workloads, these counters are updated and logged frequently enough that the superblock updates become a serialisation point in the filesystem. The value can be either 0 or 1.
With lazy-count=1, the superblock is not modified or logged on every change of the persis-tent counters. Instead, enough information is kept in other parts of the filesystem to be able to maintain the persistent counter values without needed to keep them in the superblock. This gives significant improvements in performance on some configurations. The default value is 0 (off) so you must specify lazy-count=1 if you want to make use of this feature.
-d agcount=4 :默认值是根据容量自动设置的。可以设置成1/2/4/16等等,这个参数可以调节对CPU的占用率,值越小,占用率越低。这是理论上的,在我的机器上,agcount=1反而比agcount=2的cpu占用率还高,我想这是因为我的cpu是双核的原因吧。要注意,cpu的占用率低,那每一秒处理的数据量也会降低一些。我比较了agcount=2和4,发现还是4比较好。这样一来,这个参数的设置,就是需要自己去选择的了。
然后是mount的xfs选项(关键参数nobarrier):
vi /etc/fstab
#修改挂载选项
/dev/sdb1 /data xfs defaults,noatime,nobarrier 0 0
#重新挂载
mount -o remount /data
nobarrier
Many hardware RAID have a persistent write cache which preserves it across power failure, interface resets, system crashes, etc. Using write barriers in this instance is not recommended and will in fact lower performance. Therefore, it is recommended to turn off the barrier support and mount the filesystem with "nobarrier". But take care about the hard disk write cache, which should be off.
noatime 默认的方式下linux会把文件访问的时间atime做记录,这在绝大部分的场合都是没有必要的,如果遇到机器IO负载高或是CPU WAIT高的情况,可以尝试使用noatime,疗效好,见效快。
logbufs=value
Set the number of in-memory log buffers. Valid numbers range from 2-8 inclusive. The default value is 8 buffers for filesystems with a blocksize of 64K, 4 buffers for filesystems with a blocksize of 32K, 3 buffers for filesystems with a blocksize of 16K, and 2 buffers for all other configurations. Increasing the number of buffers may increase performance on some workloads at the cost of the memory used for the additional log buffers and their associated control structures.
logbsize=value
Set the size of each in-memory log buffer. Valid sizes are 16384 (16K) and 32768 (32K). The default value for machines with more than 32MB of memory is 32768, machines with less memory use 16384 by default.
分享到:
相关推荐
Linux XFS文件系统误删除文件恢复.pdf
如果你想得到一个纯的xfs系统(系统的所有文件系统均采用XFS文件系统)话,还得将根文件系统也格式化为xfs文件系统。这实际 上是比较繁杂的一步。因为根文件系统不能被umount,所以,必须首先创建一个分区,其文件系统...
XFS 文件系统英文介绍,不错的资料 ,文件系统结构
传输特性,XFS文件系统采用优化算法,日志记录对整体文件操作影响非常小。可扩展性,XFS 是一个全64-bit的文件系统,它可以支持上百万T字节的存储空间。传输带宽,XFS能以接近裸设备I/O的性能存储数据。
Linux下XFS文件系统修复指导书
Linux系统如何创建和挂载XFS文件系统实战操作,本人已经测试通过,仅供学习。
XfS文件系统是SGI开发的高级日志文件系统,XFS极具伸缩性,非常健壮。所幸的是SGI将其移植到了Linux系统中。在Linux环境下。目前版本可用的最新XFS文件系统的为1.2版本,可以很好地工作在2.4核心下。本文将为大家...
Linux系统如何创建和挂载XFS文件系统
xfs文件系统lvm根分区扩容
通过对Windows 2000/2003/XP提供对EXT2/EXT3,XFS,Reiserfs文件系统的原生支持,Windows用户能方便地访问Linux分区的数据,并提供本地磁盘级性能。对windows下访问Linux文件有极大帮助。 用法参见:...
XfS文件系统是SGI开发的高级日志文件系统,XFS极具伸缩性,非常健壮。所幸的是SGI将其移植到了Linux系统中。在linux环境下。目前版本可用的最新XFS文件系统的为1.2版本,可以很好地工作在2.4核心下。 本文将为大家...
MySQL搭配XFS文件系统的说明。给有用的人参考。 XFS需要64位LINUX,在KERNEL 2.4+已内置了。
Linux如何扩展XFS文件系统.docx
一次Linux下testdisk+gdisk恢复XFS文件系统及数据的经历终稿.pdf
XFS文件系统在线扩充i节点
linux文件的基本管理和XFS文件系统备份恢复.pdf
Linux如何扩展XFS文件系统?.docx
第四章 文件的基本管理和XFS文件系统备份恢复本节所讲内容:4.1 Linux系统目录结构和相对/绝对路径。4.2 创建/复制/删除文件,rm -rf / 意外
SGI公司的著名的XFS文件系统设计文档。