技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统运维 --> ioprofile调查应用IO情况的利器

ioprofile调查应用IO情况的利器

浏览:1903次  出处信息

我们在做IO密集型的应用程序的时候,比如MySQL数据库,通常系统的表现取决于workload的类型。 比如我们要调优,我们就必须非常清楚的知道数据的访问规律,收集到足够的数据,用来做调优的依据。

有很多工具可以收集系统层面的,设备层面的,进程层面的IO数据,但是没有一个现成的工具可以回答我们比如应用打开了多少文件,文件的读和写的比例是多少,调用了多少次sync, 每次的数据大小是多少,调用了多少次,每次用了多少时间, 是顺序操作还是随机操作,是那个线程发起的操作。

当然如果你对系统足够熟悉的话,你可以用systemtap来编写脚本获取这些数据,也不是什么难事。但是大部分的同学没有足够的耐心去做这个。

这时候Percona同样来救助了。他提供了一整套工具来协助定位MySQL服务器的问题。这套工具适合于大部分的IO服务器。

Aspersa is a collection of open-source system utilities primarily designed to ease the work of Percona consultants. This manual is the primary documentation for Aspersa tools. Please contribute your improvements.

项目地址: http://code.google.com/p/aspersa/
ioprofile的使用文档: http://aspersa.googlecode.com/svn/html/ioprofile.html

它依赖于strace和lsof来做统计,所以在运行的时候会对目标系统产生一定的性能影响,不过还好,你可以指定收集数据的时间。

现在我们来试验下效果:

以下是引用片段:
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 
Password: 
Sun Jan 16 02:16:52 CST 2011 
     total      pread     pwrite      write      fsync filename 
  0.491959   0.000000   0.453529   0.000000   0.038430 /mnt/ibdata1
  0.296719   0.000000   0.273126   0.000000   0.023593 /mnt/ib_logfile0
  0.161494   0.061440   0.091133   0.000000   0.008921 /u01/mysql/data/ic_test/auction_auctions_0021.ibd 
  0.146056   0.036532   0.102320   0.000000   0.007204 /u01/mysql/data/ic_test/auction_auctions_0020.ibd 
  0.144570   0.007500   0.128466   0.000000   0.008604 /u01/mysql/data/ic_test/auction_auctions_0058.ibd 
  0.138565   0.054159   0.078342   0.000000   0.006064 /u01/mysql/data/ic_test/auction_auctions_0009.ibd 
  0.136702   0.017857   0.111383   0.000000   0.007462 /u01/mysql/data/ic_test/auction_auctions_0000.ibd 
... 
  
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 -c count 
Sun Jan 16 02:18:31 CST 2011 
     total      pread     pwrite      write      fsync       open filename 
      1439          0       1410          0         29          0 /mnt/ib_logfile1
       691          0          0        691          0          0 /u01/mysql/log/mysql-bin.000169 
       366         20        301          0         45          0 /u01/mysql/data/ic_test/auction_auctions_0012.ibd 
       362          0        235          0        127          0 /mnt/ibdata1
       301         18        243          0         40          0 /u01/mysql/data/ic_test/auction_auctions_0036.ibd 
       292         18        237          0         37          0 /u01/mysql/data/ic_test/auction_auctions_0026.ibd 
       291         21        230          0         40          0 /u01/mysql/data/ic_test/auction_auctions_0027.ibd 
       288         21        236          0         31          0 /u01/mysql/data/ic_test/auction_auctions_0013.ibd 
.. 
  
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 -c sizes 
Sun Jan 16 02:22:01 CST 2011 
     total      pread     pwrite      write      fsync filename 
 225542144          0  225542144          0          0 /mnt/ibdata1
   6963200     229376    6733824          0          0 /u01/mysql/data/ic_test/auction_auctions_0013.ibd 
   6094848     360448    5734400          0          0 /u01/mysql/data/ic_test/auction_auctions_0026.ibd 
   5881856     278528    5603328          0          0 /u01/mysql/data/ic_test/auction_auctions_0031.ibd 
   5849088     393216    5455872          0          0 /u01/mysql/data/ic_test/auction_auctions_0035.ibd 
   5816320     311296    5505024          0          0 /u01/mysql/data/ic_test/auction_auctions_0036.ibd 
   5701632     294912    5406720          0          0 /u01/mysql/data/ic_test/auction_auctions_0022.ibd 
   5488640     376832    5111808          0          0 /u01/mysql/data/ic_test/auction_auctions_0029.ibd 
... 
  
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 -c times
Sun Jan 16 02:25:36 CST 2011 
     total      pread     pwrite      write      fsync filename 
  0.448082   0.000000   0.413493   0.000000   0.034589 /mnt/ibdata1
  0.313238   0.000000   0.282403   0.000000   0.030835 /mnt/ib_logfile3
  0.163073   0.089651   0.065107   0.000000   0.008315 /u01/mysql/data/ic_test/auction_auctions_0005.ibd 
  0.143463   0.004427   0.130650   0.000000   0.008386 /u01/mysql/data/ic_test/auction_auctions_0011.ibd 
  0.137938   0.048641   0.080933   0.000000   0.008364 /u01/mysql/data/ic_test/auction_auctions_0021.ibd 
  0.137061   0.006563   0.120739   0.000000   0.009759 /u01/mysql/data/ic_test/auction_auctions_0018.ibd 
  0.136427   0.000000   0.000000   0.136427   0.000000 /u01/mysql/log/mysql-bin.000170 
  0.125673   0.043824   0.074042   0.000000   0.007807 /u01/mysql/data/ic_test/auction_auctions_0000.ibd 
... 
  
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 -c sizes -g filename 
Sun Jan 16 02:29:54 CST 2011 
     total      pread     pwrite      write      fsync       open filename 
 274186240          0  274186240          0          0          0 /mnt/ibdata1
   8306688     442368    7864320          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0044.ibd 
   6881280     262144    6619136          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0042.ibd 
   6799360     344064    6455296          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0053.ibd 
   6668288     475136    6193152          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0047.ibd 
   6602752     327680    6275072          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0027.ibd 
   6504448     344064    6160384          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0041.ibd 
   6275072     344064    5931008          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0024.ibd 
   6094848     393216    5701632          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0038.ibd 
   6078464     180224    5898240          0          0          0 /u01/mysql/data/ic_test/auction_auctions_0037.ibd 
... 
  
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 -c sizes -g pid 
Sun Jan 16 02:31:02 CST 2011 
     total      pread     pwrite      write      fsync pid 
 270971904      32768  270939136          0          0 21854 
  70975488          0   70975488          0          0 21844 
  67518464          0   67518464          0          0 21842 
  66797568          0   66797568          0          0 21843 
  65568768          0   65568768          0          0 21841 
... 
  
[chuba@test.flashcache.sqa.cm4 ~]$ sudo /tmp/aspersa-read-only/ioprofile -p 21826 -c sizes -g all 
Sun Jan 16 02:32:15 CST 2011 
 548216907 TOTAL 
 520120320 pwrite 
  27475968 pread 
    620619 write 
         0 fsync
 

玩的开心!

建议继续学习:

  1. 关于IO的同步,异步,阻塞,非阻塞    (阅读:14487)
  2. Linux服务器性能评估    (阅读:8200)
  3. 提升磁盘IO性能的几个技巧    (阅读:7607)
  4. I/O模型-读书笔记    (阅读:6925)
  5. Innodb IO优化-配置优化    (阅读:6665)
  6. 查看 CPU, Memory, I/O and NetFlow    (阅读:6450)
  7. blktrace 深度了解linux系统的IO运作    (阅读:6012)
  8. Linux操作系统内核3.3版本I/O Stack的流图    (阅读:5781)
  9. Linux IO协议栈框图    (阅读:5343)
  10. MySQL Tuning之浅析I/O优化    (阅读:5153)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1