MySQL安装的内存使用量最大

我使用的是Debian 8 Jessie和MariaDB。 我的mysqltuner似乎表示MariaDB可以使用内存的142%

-------- Storage Engine Statistics ------------------------------------------- [--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MRG_MyISAM [--] Data in InnoDB tables: 2G (Tables: 79) [--] Data in MyISAM tables: 96M (Tables: 146) [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 52) [!!] Total fragmented tables: 34 -------- Security Recommendations ------------------------------------------- [OK] All database users have passwords assigned -------- Performance Metrics ------------------------------------------------- [--] Up for: 1d 16h 44m 38s (73M q [502.853 qps], 196K conn, TX: 572B, RX: 14B) [--] Reads / Writes: 97% / 3% [--] Total buffers: 17.3G global + 56.2M per thread (500 max threads) [!!] Maximum possible memory usage: 44.8G (142% of installed RAM) [OK] Slow queries: 0% (2K/73M) [OK] Highest usage of available connections: 28% (141/500) [OK] Key buffer size / total MyISAM indexes: 1.0G/32.6M [OK] Key buffer hit rate: 100.0% (132M cached / 53K reads) [OK] Query cache efficiency: 44.9% (50M cached / 113M selects) [!!] Query cache prunes per day: 260596 [OK] Sorts requiring temporary tables: 0% (2K temp sorts / 2M sorts) [OK] Temporary tables created on disk: 21% (6K on disk / 28K total) [OK] Thread cache hit rate: 99% (141 created / 196K connections) [OK] Table cache hit rate: 72% (500 open / 692 opened) [OK] Open file limit used: 17% (429/2K) [OK] Table locks acquired immediately: 99% (25M immediate / 25M locks) [OK] InnoDB buffer pool / data size: 16.0G/2.4G [!!] InnoDB log waits: 30 

innodb_buffer_pool_size在16Go,为32Go RAM应该是好的,我不知道该怎么做优化。

事情是,我在服务器中的内存一般用法总是低于89%(加上caching)。 MariaDB实际上使用了50.6%的RAM。

这是my.cnf中的主要variables,我调整了可能对此有影响:

 max_connections = 100 max_heap_table_size = 64M read_buffer_size = 4M read_rnd_buffer_size = 32M sort_buffer_size = 8M query_cache_size = 256M query_cache_limit = 4M query_cache_type = 1 query_cache_strip_comments =1 thread_stack = 192K transaction_isolation = READ-COMMITTED tmp_table_size = 64M nnodb_additional_mem_pool_size = 16M innodb_buffer_pool_size = 16G thread_cache_size = 4M max_connections = 500 join_buffer_size = 12M interactive_timeout = 30 wait_timeout = 30 open_files_limit = 800 innodb_file_per_table key_buffer_size = 1G table_open_cache = 500 innodb_log_file_size = 256M 

在我的configuration中是不正确的?

通过从my.cnf中删除以下内容,可以实现内存占用的额外减less,从而允许默认设置为您的系统提供服务。

 sort_buffer_size read_buffer_size read_rnd_buffer_size join_buffer_size 

考虑在my.cnf中更改或添加以下内容

 key_buffer_size = 164M # you already have 132m cached per MySqlTuner thread_cache_size = 100 # CAP suggested in 8.0 to avoid overload 

创build了141个线程,在您的1天16小时正常运行时间内为196K连接提供服务。 这将降低高CPU使用率创build/打破连接。

现在保持你的innodb_buffer_pool_size为16G是好的,因为你每个MySQLTuner只有2.4G的数据。

SEO DEVSbuild议的其他项目是超级。

使用mysqlcalculator.com快速检查大致的RAM利用率

你已经完成了你的设置和SQL数据库设置为可能的过载,也有一个重复的最大连接。 对于32GB的服务器,my.cnf应该看起来更像这样。 改变你的设置,以匹配下面的。

 key_buffer = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 max_connections = 250 table_cache = 4K wait_timeout = 1200 query_cache_limit = 1M query_cache_size = 128M join_buffer_size = 2M expire_logs_days = 10 max_binlog_size = 100M innodb_buffer_pool_size = 26G [mysqldump] quick quote-names max_allowed_packet = 16M 

希望这可以帮助