为什么我的服务器有很多mysql线程?

为什么我的服务器有很多mysql线程?

我注意到我的服务器消耗了近 500 MB 的 RAM,并且启动了 19 个线程,如下图所示。

MYSQL 线程顶部图像:

在此处输入图片描述

配置如下:

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.41-3ubuntu12
[OK] Operating on 32-bit architecture with less than 2GB RAM

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 136M (Tables: 256)
[--] Data in InnoDB tables: 85M (Tables: 29)
[--] Data in MEMORY tables: 126K (Tables: 1)
[!!] Total fragmented tables: 70

-------- Performance Metrics -------------------------------------------------
[--] Up for: 8d 18h 35m 35s (8M q [11.203 qps], 509K conn, TX: 4B, RX: 934M)
[--] Reads / Writes: 56% / 44%
[--] Total buffers: 72.0M global + 2.8M per thread (100 max threads)
[OK] Maximum possible memory usage: 347.8M (33% of installed RAM)
[OK] Slow queries: 0% (74/8M)
[OK] Highest usage of available connections: 16% (16/100)
[OK] Key buffer size / total MyISAM indexes: 16.0M/58.1M
[OK] Key buffer hit rate: 99.9% (317M cached / 259K reads)
[OK] Query cache efficiency: 61.9% (3M cached / 4M selects)
[!!] Query cache prunes per day: 60422
[OK] Sorts requiring temporary tables: 0% (5 temp sorts / 328K sorts)
[!!] Joins performed without indexes: 18909
[OK] Temporary tables created on disk: 22% (32K on disk / 140K total)
[OK] Thread cache hit rate: 99% (54 created / 509K connections)
[!!] Table cache hit rate: 0% (64 open / 40K opened)
[OK] Open file limit used: 10% (112/1K)
[OK] Table locks acquired immediately: 99% (4M immediate / 4M locks)
[!!] InnoDB data size / buffer pool: 86.0M/8.0M

出了什么问题或者我该如何减少 mysqld 线程数?

服务器没有特殊流量,它是一个托管两个中低流量网站的 vps。

答案1

您可能在 PHP 中打开了持久连接。

但是500MB对于MYSQL来说并不算大,而是小。

该报告存在几个问题

  1. 未使用索引执行的连接:18909
    您需要查看以添加外部列的索引
  2. 表缓存命中率:0%
    需要增加mysql的表缓存值
  3. InnoDB 数据大小/缓冲池:86.0M/8.0M
    增加 innodb 缓冲区值

相关内容