xfs文件系统优化

某云一直在xfs做为其底层文件系统,性能不错。我本身也试了一下,默认参数下性能不如ext4文件系统。上网找了一些文章,作了一下调优。发现性能日新月异。node

性能的奥秘在于格式化时候的参数:

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而不担忧性能的损失。linux

  • -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比较好。这样一来,这个参数的设置,就是须要本身去选择的了。测试

通过以上优化,通过测试,性能有了大幅度提高。优化