mysql数据库经常无法连接的问题
mysql> show variables like '%query_cache%';
+------------------------------+-----------+
| Variable_name | Value |
+------------------------------+-----------+
| have_query_cache | YES |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 536870912 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
+------------------------------+-----------+
mysql> show status like '%Qcache%';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| Qcache_free_blocks | 9939 |
| Qcache_free_memory | 480086640 |
| Qcache_hits | 65276811 |
| Qcache_inserts | 41509403 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 2065484 |
| Qcache_queries_in_cache | 22970 |
| Qcache_total_blocks | 56252 |
+-------------------------+-----------+
最关键的参数是Qcache_lowmem_prunes ,如果它是一个非0的参数,那么说明服务器运行不正常,会有缓存被排除
mysql> show status like 'Com_sel%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select | 1 |
+---------------+-------+
如果发现不正常只需要修改/etc/my.cnf中的
query_cache_size = 512M
加大cache size即可解决
最后别忘记重启数据库.
评论: