AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 130294
Accepted
amir jj
amir jj
Asked: 2016-02-25 02:02:07 +0800 CST2016-02-25 02:02:07 +0800 CST 2016-02-25 02:02:07 +0800 CST

innodb 内存泄漏

  • 772

我有 MySQL 服务器 5.6,我使用压力测试来评估它的性能。测试后的结果mysqltuner.pl如下:

root@master-1:/home/debian# perl mysqltuner.pl
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:  >>  MySQLTuner 1.6.4 - Major Hayden <[email protected]>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.6.29-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM 
[--] Data in InnoDB tables: 34G (Tables: 29)
[!!] Total fragmented tables: 4

-------- Security Recommendations  -------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

-------- CVE Security Recommendations  ---------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1h 56m 26s (4M q [592.634 qps], 398 conn, TX: 8B, RX: 6B)
[--] Reads / Writes: 81% / 19%
[--] Binary logging is enabled (GTID MODE: OFF)
[--] Total buffers: 1.0G global + 1.1M per thread (8190 max threads)
[OK] Maximum reached memory usage: 1.1G (4.63% of installed RAM)
[OK] Maximum possible memory usage: 9.5G (40.45% of installed RAM)
[OK] Slow queries: 0% (0/4M)
[OK] Highest usage of available connections: 0% (44/8190)
[OK] Aborted connections: 0.75%  (3/398)
[!!] Query cache is disabled
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 2 sorts)
[OK] Temporary tables created on disk: 0% (0 on disk / 27 total)
[OK] Thread cache hit rate: 84% (62 created / 398 connections)
[OK] Table cache hit rate: 75% (309 open / 408 opened)
[OK] Open file limit used: 0% (54/9K)
[OK] Table locks acquired immediately: 100% (4M immediate / 4M locks)
[OK] Binlog cache memory access: 100.00% ( 704225 Memory / 704225 Total)

-------- MyISAM Metrics ------------------------------------------------------
[!!] Key buffer used: 18.2% (3M used / 16M cache)
[OK] Key buffer size / total MyISAM indexes: 16.0M/95.0K
[!!] Read Key buffer hit rate: 80.0% (5 cached / 1 reads)

-------- InnoDB Metrics ------------------------------------------------------
[--] InnoDB is enabled.
[!!] InnoDB buffer pool / data size: 512.0M/34.2G
[!!] InnoDB buffer pool <= 1G and innodb_buffer_pool_instances(!=1).
[OK] InnoDB Used buffer: 96.95% (31769 used/ 32767 total)
[OK] InnoDB Read buffer efficiency: 99.83% (94182005 hits/ 94340114 total)
[!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
[OK] InnoDB log waits: 0.00% (0 waits / 178758 writes)

-------- ThreadPool Metrics --------------------------------------------------
[--] ThreadPool stat is disabled.

-------- AriaDB Metrics ------------------------------------------------------
[--] AriaDB is disabled.

-------- TokuDB Metrics ------------------------------------------------------
[--] TokuDB is disabled.

-------- Galera Metrics ------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -------------------------------------------------
[--] This server is acting as master for 2 server(s).
[!!] This replication slave is running with the read_only option disabled.
[OK] This replication slave is up to date with master.

-------- Recommendations -----------------------------------------------------

然后我停止压力测试脚本,我发现内存几乎已满,MySQL 不会释放它(即使在一天没有任何查询并重新启动 MySQL 之后),类似于内存泄漏或错误。在my.cnf缓冲区大小中,innodb_buffer_pool_size=512M并且在将其更改为之后,2G但没有发生任何有用的事情。在本教程中,我使用了以下命令,但我看到了一些不好的东西:

询问:

select
page_type as Page_Type,
sum(data_size)/1024/1024 as Size_in_MB
from information_schema.innodb_buffer_page
group by page_type
order by Size_in_MB desc;

结果 :

+--------------------------------+------------+------------+------------+
| Table_Name                     | Index_Name | Page_Count | Size_in_MB |
+--------------------------------+------------+------------+------------+
| `SYS_COLUMNS`                  | CLUST_IND  |          1 | 0.01321316 |
| `SYS_INDEXES`                  | CLUST_IND  |          1 | 0.00615215 |
| `SYS_FIELDS`                   | CLUST_IND  |          1 | 0.00364017 |
| `SYS_TABLES`                   | CLUST_IND  |          1 | 0.00293446 |
| `SYS_FOREIGN`                  | FOR_IND    |          1 | 0.00023651 |
| `SYS_FOREIGN`                  | REF_IND    |          1 | 0.00022316 |
| NULL                           | NULL       |     131055 | 0.00000000 |
| `mysql`.`slave_relay_log_info` | PRIMARY    |          1 | 0.00000000 |
| `mysql`.`slave_master_info`    | PRIMARY    |          1 | 0.00000000 |
| `mysql`.`slave_worker_info`    | PRIMARY    |          1 | 0.00000000 |
+--------------------------------+------------+------------+------------+
10 rows in set (1.49 sec)

如您所见,一行是NULL并且有131055page_count。缓冲池中页面类型的结果如下:

询问:

select
page_type as Page_Type,
sum(data_size)/1024/1024 as Size_in_MB
from information_schema.innodb_buffer_page
group by page_type
order by Size_in_MB desc;

结果:

+-------------------+------------+
| Page_Type         | Size_in_MB |
+-------------------+------------+
| INDEX             | 0.02639961 |
| IBUF_INDEX        | 0.00000000 |
| INODE             | 0.00000000 |
| IBUF_BITMAP       | 0.00000000 |
| SYSTEM            | 0.00000000 |
| UNKNOWN           | 0.00000000 |
| FILE_SPACE_HEADER | 0.00000000 |
| UNDO_LOG          | 0.00000000 |
| TRX_SYSTEM        | 0.00000000 |
+-------------------+------------+
9 rows in set (1.04 sec)

结果htop如下:

在此处输入图像描述

当 MySQL 服务器上没有任何负载时,您可以查看缓存大小使用情况和mysqld进程。

我不明白为什么没有释放内存(缓存),或者我想知道这是否是一个错误。

mysql innodb
  • 1 1 个回答
  • 2753 Views

1 个回答

  • Voted
  1. Best Answer
    Rick James
    2016-03-03T21:45:29+08:002016-03-03T21:45:29+08:00

    (key_buffer用于缓存 MyISAM索引)和innodb_buffer_pool(用于 InnoDB 数据和索引)增长到 my.cnf 中指示的最大值;之后它们不会缩小。这不是内存泄漏。两者都是缓存。

    我希望你只使用 InnoDB。如果是这样,请使用以下设置:

    key_buffer_size = 40M       -- the system tables need it
    innodb_buffer_pool_size =   -- about 70% of available RAM.
    

    忽略 Tuner 提到的“碎片化”表;这是假的。

    • 2

相关问题

  • 是否有任何 MySQL 基准测试工具?[关闭]

  • 我在哪里可以找到mysql慢日志?

  • 如何优化大型数据库的 mysqldump?

  • 什么时候是使用 MariaDB 而不是 MySQL 的合适时机,为什么?

  • 组如何跟踪数据库架构更改?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve