MySQL高内存使用率?

马丁·史密斯

我试图找出正在使用我的RAM的内存。我做了一些检查,看起来mysqld引起了较高的RAM使用率。的输出free -ghtoptopshowprocesslist;没有太大的帮助。

免费-g

                 total       used       free     shared    buffers     cached
    Mem:           125        120          5          0          1        101
    -/+ buffers/cache:         17        108
    Swap:            0          0          0

如果我是对的,这表明我在125 GB内存中只有5 GB可用内存。

停止

1  [|||                                           4.6%]   9  [                                              0.0%]     17 [||                                            1.4%]   25 [                                              0.0%]
  2  [|||||||||||||||||||||||                      44.4%]   10 [                                              0.0%]     18 [                                              0.0%]   26 [|                                             0.5%]
  3  [|||||||                                      12.4%]   11 [|                                             0.5%]     19 [                                              0.0%]   27 [                                              0.0%]
  4  [|||||                                         7.5%]   12 [                                              0.0%]     20 [                                              0.0%]   28 [                                              0.0%]
  5  [||||||||                                     14.2%]   13 [                                              0.0%]     21 [                                              0.0%]   29 [                                              0.0%]
  6  [||||                                          4.8%]   14 [                                              0.0%]     22 [|                                             0.5%]   30 [                                              0.0%]
  7  [                                              0.0%]   15 [|                                             0.5%]     23 [||                                            2.4%]   31 [                                              0.0%]
  8  [|                                             0.5%]   16 [|                                             0.9%]     24 [||||                                          5.6%]   32 [                                              0.0%]
  Mem[||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||17367/128886MB]     Tasks: 93, 90 thr; 2 running
  Swp[                                                                                                    0/1021MB]     Load average: 1.01 0.96 0.97
                                                                                                                        Uptime: 18 days, 05:43:05

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
27655 mysql      20   0 66.8G 6166M 11220 S 69.2  4.8  5:25.06 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
28300 mysql      20   0 66.8G 6166M 11220 R 33.4  4.8  0:51.03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27743 mysql      20   0 66.8G 6166M 11220 S 35.8  4.8  1:26.46 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
28064 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  1:33.48 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
28007 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  1:27.01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27727 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.44 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27692 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27697 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27725 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.39 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27724 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.08 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27691 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27693 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.11 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27694 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.06 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27695 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.10 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27696 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.08 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27698 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.02 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27699 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27700 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27726 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
27739 mysql      20   0 66.8G 6166M 11220 S  0.0  4.8  0:00.00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysql
 8395 clamav     20   0  799M  534M 24264 S  0.0  0.4  0:00.00 /usr/sbin/clamd --foreground=true
 8266 clamav     20   0  799M  534M 24264 S  0.0  0.4  9:07.15 /usr/sbin/clamd --foreground=true
12977 amavis     20   0  316M  120M  8448 S  0.0  0.1  0:01.46 /usr/sbin/amavisd-new (ch10-avail)
 8190 amavis     20   0  316M  120M  8448 S  0.0  0.1  0:01.64 /usr/sbin/amavisd-new (ch11-avail)
24641 amavis     20   0  242M  116M  5692 S  0.0  0.1  0:11.26 /usr/sbin/amavisd-new (master)

htop输出表明mysqld导致较高的RAM使用率,不是吗?

最佳

   top - 18:12:15 up 18 days,  5:55,  1 user,  load average: 0.98, 1.00, 1.00
Tasks: 475 total,   1 running, 474 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.7 us,  0.2 sy,  0.0 ni, 97.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:  13198007+total, 12738310+used,  4596968 free,  1927068 buffers
KiB Swap:  1046520 total,        0 used,  1046520 free. 10698358+cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
27655 mysql     20   0 66.840g 6.662g  11220 S  62.3  5.3  12:50.24 mysqld
22288 web1      20   0  367640  75964  52492 S  29.2  0.1   6:55.78 php-cgi
16897 www-data  20   0 2067372  28632   7380 S   1.0  0.0   7:20.03 apache2
29318 root      20   0   26512   3440   2576 R   0.7  0.0   0:01.49 top
31235 root      20   0  775232  12736   5984 S   0.3  0.0  16:57.05 fail2ban-server
    1 root      20   0  177980   6764   3256 S   0.0  0.0   0:55.74 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.13 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:04.97 ksoftirqd/0
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
    6 root      20   0       0      0      0 S   0.0  0.0   2:56.16 kworker/u64:0
    8 root      20   0       0      0      0 S   0.0  0.0  16:31.60 rcu_sched
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.95 migration/0

但是随后top显示mysqld仅使用5.3%的RAM。

显示过程清单;

Kill Kill   734     phpmyadmin  localhost   NULL    Sleep   0       NULL
Kill Kill   735     root    localhost   NULL    Query   0   NULL    SHOW PROCESSLIST

显示过程清单;为空,这是事实,因为只有一个网站正在开发中,没有任何流量。

mysqltuner.pl

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 24m 14s (175K q [120.627 qps], 1K conn, TX: 2G, RX: 37M)
[--] Reads / Writes: 95% / 5%
[--] Binary logging is disabled
[--] Physical Memory     : 125.9G
[--] Max MySQL memory    : 62.4G
[--] Other process memory: 1.1G
[--] Total buffers: 62.0G global + 2.7M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 62.0G (49.29% of installed RAM)
[OK] Maximum possible memory usage: 62.4G (49.60% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/175K)
[OK] Highest usage of available connections: 2% (4/151)
[OK] Aborted connections: 0.42%  (5/1182)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 1% (988 temp sorts / 57K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 81% (13K on disk / 16K total)
[OK] Thread cache hit rate: 99% (4 created / 1K connections)
[OK] Table cache hit rate: 96% (209 open / 216 opened)
[OK] Open file limit used: 21% (225/1K)
[OK] Table locks acquired immediately: 100% (204K immediate / 204K locks)

(...)

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysql/error.log file
    Control error line(s) into /var/log/mysql/error.log file
    MySQL started within last 24 hours - recommendations may be inaccurate
    Enable the slow query log to troubleshoot bad queries
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Consider installing Sys schema from https://github.com/mysql/mysql-sys
    Read this before changing innodb_log_file_size and/or innodb_log_files_in_group: bit.ly/2wgkDvS
Variables to adjust:
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    innodb_log_file_size should be (=7G) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

mysql error.log为空。有什么想法吗?

瑞·里贝罗(Rui F Ribeiro)

对于RAM,从free命令输出中,您已经获得了free + buffers + cached-> 5 + 1 + 101 = 107 GB。

因此,实际上您的程序正在使用,再次从free输出中使用了120GB RAM-107 GB可用+缓冲区+缓存= 13GB

内核可以随时为其他需求回收缓冲区和缓存,并且通常会随着时间的增长而增长。但是,随着它们的增长,当内存不足时,它们也会收缩。

正如你也可以看到,无论是在freepsmysqltuner输出,MySQL的RAM的使用似乎主要缓冲区。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Percona 5.6高内存使用率

来自分类Dev

STXXL的高内存使用率

来自分类Dev

Gitlab CE的高内存使用率

来自分类Dev

python中的高内存使用率

来自分类Dev

Google polyline高内存使用率?

来自分类Dev

使用休眠时内存使用率高

来自分类Dev

高内存使用率,但没有进程在使用它

来自分类Dev

使用Python多处理的高内存使用率

来自分类Dev

Pythons本地tarfile lib的高内存使用率

来自分类Dev

字符串和高内存使用率

来自分类Dev

attoparsec高内存使用率读取大文件

来自分类Dev

Gradle守护程序的高内存使用率

来自分类Dev

cloudampq中的MassTransit高内存使用率

来自分类Dev

Windows 10高内存使用率(未知原因)

来自分类Dev

svchost.exe的高内存使用率-wuauserv

来自分类Dev

iOS的高内存使用率是多少?

来自分类Dev

字符串和高内存使用率

来自分类Dev

屏幕关闭时Windows 10的高内存使用率

来自分类Dev

系统和压缩内存:高磁盘使用率

来自分类Dev

svchost.exe(netsvcs)高内存使用率

来自分类Dev

Windows 10高驱动程序内存使用率

来自分类Dev

Windows 8.1 64位:高内存使用率

来自分类Dev

Windows Phone图像的高内存使用率

来自分类Dev

Ubuntu Process高内存使用率(将近99%)

来自分类Dev

python 2简单的for循环高内存使用率

来自分类Dev

Xorg的高使用率

来自分类Dev

C#实体框架内存使用率高,内存泄漏?

来自分类Dev

内存使用率异常(内存泄漏?)

来自分类Dev

没有应用程序的高内存使用率。无法在Android Studio上使用