table_open_cache与max_connections与open_files_limit

一般来讲:

table_open_cache = max_connections * N  ,N代表一个查询中最多打开的表数量。

table_definition_cache = 设置足够大。

对于open_files_limit,它代表同一时间点能打开的文件数上限,这里有两篇文章:http://www.orczhou.com/index.php/2010/10/mysql-open-file-limit/,http://blog.csdn.net/fbjwying2/article/details/6323897,里面具体的说了open_files_limit与哪些因素有关。我这里只简单说下我的理解。

open_files_limit的值取决于三个数值:open_files_limit,max_connections*5,10+max_connections+table_cache_size*2。真实值是这三个值的最大值。

有一种情况是上面得出的最大值超过了ulimit -n设置的值时,有可能通过show variables看到值却不是真实的。因为运行于os里的进程最终会受到os的影响。所以最好就是设置ulimit -n 与 show variables like 'open_files_limit'里一样。

show global 里的open_files表示当前此时此刻打开文件的数量,如果与open_files_limit非常接近,则就要提高open_files_limit的值。

show global 里的opened_tables表示已经打开表的数量,如果与table_open_cache非常接近,则就要提高table_open_cache的值。但不要一味的增加,还要看当前open_tables的值。

注意:show global 里 open_files 代表当前此时此刻打开的文件数,opened_files代表从服务最近一次启动到现在打开的文件数。

open_tables 代表当前此时此刻打开的表,opened_tables代表从服务最近一次启动到现在打开的表。

opened_tables -----> table_open_cache.

open_files       -----> open_files_limit.

posted @ 2011-08-30 18:00  雪刚  阅读(1860)  评论(0编辑  收藏  举报