Optimizing InnoDB Disk I/O


本文转载自:http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-diskio.html


Optimizing InnoDB Disk I/O

If you follow the best practices for database design and the tuning techniques for SQL operations, but your database is still slowed by heavy disk I/O activity, explore these low-level techniques related to disk I/O. If the Unixtop tool or the Windows Task Manager shows that the CPU usage percentage with your workload is less than 70%, your workload is probably disk-bound.

  • When table data is cached in the InnoDB buffer pool, it can be processed over and over by queries without requiring any disk I/O. Specify the size of the buffer pool with theinnodb_buffer_pool_size option. This memory area is important enough that busy databases often specify a size approximately 80% of the amount of physical memory. For more information, seeSection 8.9.1, “The InnoDB Buffer Pool”.

  • In some versions of GNU/Linux and Unix, flushing files to disk with the Unix fsync() call (which InnoDB uses by default) and similar methods is surprisingly slow. If database write performance is an issue, conduct benchmarks with theinnodb_flush_method parameter set to O_DSYNC.

  • When using the InnoDB storage engine on Solaris 10 for x86_64 architecture (AMD Opteron), use direct I/O forInnoDB-related files, to avoid degradation of InnoDB performance. To use direct I/O for an entire UFS file system used for storingInnoDB-related files, mount it with the forcedirectio option; see mount_ufs(1M). (The default on Solaris 10/x86_64 isnot to use this option.) To apply direct I/O only toInnoDB file operations rather than the whole file system, setinnodb_flush_method = O_DIRECT. With this setting,InnoDB calls directio() instead offcntl() for I/O to data files (not for I/O to log files).

  • When using the InnoDB storage engine with a largeinnodb_buffer_pool_size value on any release of Solaris 2.6 and up and any platform (sparc/x86/x64/amd64), conduct benchmarks withInnoDB data files and log files on raw devices or on a separate direct I/O UFS file system, using theforcedirectio mount option as described earlier. (It is necessary to use the mount option rather than settinginnodb_flush_method if you want direct I/O for the log files.) Users of the Veritas file system VxFS should use theconvosync=direct mount option.

    Do not place other MySQL data files, such as those for MyISAM tables, on a direct I/O file system. Executables or librariesmust not be placed on a direct I/O file system.

  • If you have additional storage devices available to set up a RAID configuration or symbolic links to different disks,Section 8.11.3, “Optimizing Disk I/O” for additional low-level I/O tips. 


注:近期参加MySQL运维学习,老师推荐该文章作为学习和技术提高的扩展阅读,先记录到自己的博客中,随后慢慢消化、学习、提高。本文与MySQL数据库 “性能优化”主题有关。


你可能感兴趣的:(mysql)