Chinaunix首页 | 论坛 | 博客
  • 博客访问: 145569
  • 博文数量: 43
  • 博客积分: 15
  • 博客等级: 民兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-04 00:08
个人简介

Know C, C++ and shell programming, math and sport is my favour too. VIM Fans.

文章分类

全部博文(43)

文章存档

2015年(1)

2014年(27)

2013年(15)

我的朋友

分类: LINUX

2014-08-09 14:15:04

xfs文件系统优化

先贴出优化前后的对比,只是简单的用dd命令测试了一下而已,不怎么专业。写的性能确实提高不少,读的性能没有太大变化。
优化前:
#写性能
[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
阅读(1692) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~