Open_tables Opened_tables table_open_cache
2016-03-23 11:08
375 查看
今天开发说应用链接数据库比较慢,定位后发现是table_open_cache太小了引起的问题。
如果你发现Opened_tables比较大并且一直再增大,很可能是table_open_cache设置太小了,导致每次链接数据库都要去打开表,这也会造成链接数据库比较慢。
测试:
如果你发现Opened_tables比较大并且一直再增大,很可能是table_open_cache设置太小了,导致每次链接数据库都要去打开表,这也会造成链接数据库比较慢。
Open_tables : The number of tables that are open. Opened_tables : The number of tables that have been opened. If Opened_tables is big, your table_open_cache value is probably too small. table_open_cache :The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. You can check whether you need to increase the table cache by checking the Opened_tables status variable. If the value of Opened_tables is large and you do not use FLUSH TABLES often (which just forces all tables to be closed and reopened), then you should increase the value of the table_open_cache variable. For more information about the table cache,
测试:
mysql> show variables like 'table_open_cache'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | table_open_cache | 4 | +------------------+-------+ 1 row in set (0.00 sec) mysql> show global status like 'open%tables%'; +---------------+----------+ | Variable_name | Value | +---------------+----------+ | Open_tables | 4 | | Opened_tables | 11412131 | +---------------+----------+ 2 rows in set (0.00 sec) mysql> exit [root@slave159 bin]# mysql -uroot -h192.168.60.204 -p1234 pva1 -- 说明:3s左右才登陆 mysql> show global status like 'open%tables%'; +---------------+----------+ | Variable_name | Value | +---------------+----------+ | Open_tables | 4 | | Opened_tables | 11413673 | +---------------+----------+ 2 rows in set (0.01 sec) mysql> select 11413673-11412131; +-------------------+ | 11413673-11412131 | +-------------------+ | 1542 | +-------------------+ 1 row in set (0.00 sec) mysql> set global table_open_cache=2000; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye [root@slave159 bin]# mysql -uroot -h192.168.60.204 -p1234 pva1 -- 说明:3s左右才登陆 mysql> show global status like 'open%tables%'; +---------------+----------+ | Variable_name | Value | +---------------+----------+ | Open_tables | 574 | | Opened_tables | 11433986 | +---------------+----------+ mysql> exit Bye [root@slave159 bin]# mysql -uroot -h192.168.60.204 -p1234 pva1 -- 说明:1s内就登陆了 mysql> show global status like 'open%tables%'; +---------------+----------+ | Variable_name | Value | +---------------+----------+ | Open_tables | 574 | | Opened_tables | 11433986 | +---------------+----------+
相关文章推荐
- 用URL来操作Hadoop
- 几个shell自动化脚本(定期清理、磁盘空间、搜寻关键字)
- centos下安装JDK8的方法
- -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable
- linux 高精度计时方法
- linux 下VSFTP 530 Permission denied错误的解决方法
- 效果插件网站收集
- 怎么在Mac上安装Tomcat 7
- 关闭log4j 输出 DEBUG org.apache.commons.beanutils.*
- 第三章 HADOOP分布式文件系统 第一节 HDFS设计
- shell--读取文件
- owTforewoP.231
- Linux初学者学习资料
- linux系统垃圾清理
- Hadoop contrib介绍
- docker 镜像和容器的批量清理
- Linux下.a库文件的调用
- Git Bash+EGit在项目中配合使用最常用方法总结(根据场景使用)
- linux java 环境变量配置
- opencv来实现图片拼接