您的位置:首页 > 数据库 > SQL

mysql Innodb simple optimization

2011-12-27 18:30 323 查看
1. 配置文件路径 /etc/my.cnf

2. INNODB Specific options

  a). innodb_buffer_pool_size, InnoDB uses a buffer pool to cache both indexes and row data. The bigger you set this the less disk I/O is needed to access data in tables. On a dedicated database server you may set this parameter up to 80% of the machine physical memory size. Do not set it too large, though, because competition of the physical memory may cause paging in the operating system. Note that on 32bit systems you might be limited to 2-3.5G of user level memory per process, so do not set it too high. //服务器是64位的solaris,内存10G,由于mysql和应用都在一台机器上,这里设置5G。

  b). innodb_flush_log_at_trx_commit, If set to 1, InnoDB will flush (fsync) the transaction logs to the disk at each commit, which offers full ACID behavior. If you are willing to compromise this safety, and you are running small transactions, you may set this to 0 or 2 to reduce disk I/O to the logs. Value 0 means that the log is only written to the log file and the log file flushed to disk approximately once per second. Value 2 means the log is written to the log file at each commit, but the log file is only flushed to disk approximately once persecond. //设置成1最保险,2相对保险,0不太保险,既然不保险,性能就有所提升,这里设置成2。

  c). innodb_log_file_size, Size of each log file in a log group. You should set the combined size of log files to about 25%-100% of your buffer pool size to avoid unneeded buffer pool flush activity on log file overwrite. However, note that a larger logfile size will increase the time needed for the recovery process. //这里设置256M。

  d). innodb_thread_concurrency, Even with current Innodb Scalability Fixes having limited concurrency helps. The actual number may be higher or lower depending on your application and default which is 8 is decent start. //这时设置16。

  e). thread_concurrency, 对mysql的性能影响很大,在多个cpu(或多核)的情况下,错误设置了thread_concurrency的值,会导致mysql不能充分利用多cpu(或多核),出现同一时刻只能一个cpu(或核)在工作的情况。应设为CPU核数的2倍. 2个双核的cpu, thread_concurrency的值应为8.

  f). thread_cache_size, How many threads we should keep in a cache for resue. When a client disconnects, the client's threads are put in the cache if there aren't more than thread_cache_size threads from before. This greatly reduces the amount of thread creations needed if you have a lot of new connections. (Normally this doesn't give a notable performance improvement if you have a good thread implementation.) //从配置文件的说明看,修改这个不会有多少性能提升,设置32或64。

3. 参考资料

  Innodb Performance Optimization Basics by Peter Zaitsev
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: