I have a Directadmin/CentOS 7.0 Dedicate with 128 GB RAM and 2x CPU 10 core 2.0 Ghz
I ran the MySQLTuner script, and followed the recommendations that they gave, but it’s still recommending increases, while telling me that MySQL’s maximum memory usage is dangerously high.
My current config in my my.cnf file is:
>> MySQLTuner 1.7.19 - 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 10.4.11-MariaDB
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mysql.log exists
[--] Log file: /var/log/mysql.log(0B)
[OK] Log file /var/log/mysql.log is readable.
[!!] Log file /var/log/mysql.log is empty
[OK] Log file /var/log/mysql.log is smaller than 32 Mb
[OK] /var/log/mysql.log doesn't contain any warning.
[OK] /var/log/mysql.log doesn't contain any error.
[--] 0 start(s) detected in /var/log/mysql.log
[--] 0 shutdown(s) detected in /var/log/mysql.log
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in MyISAM tables: 426.0M (Tables: 34)
[--] Data in InnoDB tables: 175.6M (Tables: 29)
[OK] Total fragmented tables: 0
-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
-------- 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: 22m 0s (2M q [2K qps], 3K conn, TX: 2G, RX: 317M)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory : 125.7G
[--] Max MySQL memory : 131098.3G
[--] Other process memory: 0B
[--] Total buffers: 15.6G global + 32.0G per thread (4096 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 271.7G (216.19% of installed RAM)
[!!] Maximum possible memory usage: 131098.3G (104328.03% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/2M)
[OK] Highest usage of available connections: 0% (8/4096)
[OK] Aborted connections: 0.00% (0/3914)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[OK] Query cache efficiency: 48.9% (2M cached / 5M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 43K sorts)
[!!] Joins performed without indexes: 415
[!!] Temporary tables created on disk: 64% (8K on disk / 12K total)
[OK] Thread cache hit rate: 99% (8 created / 3K connections)
[OK] Table cache hit rate: 96% (187 open / 193 opened)
[OK] table_definition_cache(400) is upper than number of tables(329)
[OK] Open file limit used: 0% (148/20K)
[OK] Table locks acquired immediately: 99% (70K immediate / 70K locks)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema is installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 40 thread(s).
[--] Using default value is good enough for your version (10.4.11-MariaDB)
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 23.4% (125M used / 536M cache)
[OK] Key buffer size / total MyISAM indexes: 512.0M/53.6M
[OK] Read Key buffer hit rate: 100.0% (121M cached / 27K reads)
[OK] Write Key buffer hit rate: 99.8% (636 cached / 635 writes)
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 8.0G/175.6M
[OK] Ratio InnoDB log file size / InnoDB Buffer pool size: 1.0G * 2/8.0G should be equal to 25%
[OK] InnoDB buffer pool instances: 8
[--] Number of InnoDB Buffer Pool Chunk : 64 for 8 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 99.99% (58380753 hits/ 58389392 total)
[!!] InnoDB Write Log efficiency: 125.23% (139 hits/ 111 total)
[OK] InnoDB log waits: 0.00% (0 waits / 250 writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/368.0K
[OK] Aria pagecache hit rate: 97.7% (357K cached / 8K reads)
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
MySQL was started within the last 24 hours - recommendations may be inaccurate
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
(specially the conclusions at the bottom of the page).
Temporary table size is already large - reduce result set size
Reduce your SELECT DISTINCT queries without LIMIT clauses
Performance schema should be activated for better diagnostics
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_size (=0)
query_cache_type (=0)
join_buffer_size (> 32.0G, or always use indexes with JOINs)
performance_schema = ON enable PFS
and this is my.cnf config
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
max_connections = 4096
key_buffer_size = 512M
max_allowed_packet = 1024M
query_cache_limit = 256M
query_cache_size = 5G
query_cache_type = 1
innodb_log_file_size=1G
innodb_buffer_pool_size=8G
max_heap_table_size=2G
join_buffer_size=32G
tmp_table_size=2G
thread_cache_size=512
Does anyone have any recommendations with what to do now?
3
Answers
join_buffer_size=32G
seems high to me and is likely the cause of the memory warning, especially consideringmax_connections = 4096
and MySQLTuner basically multiplies these two numbers to estimate memory consumption. I thinkmax_connections
is also high and nowhere near what is required according to the information given right now, seeHighest usage of available connections: 0% (8/4096)
.MySQLTuner gives some hints regarding improvement of queries, which I would follow first. (Make sure JOINs use indexes, reduce result set size, …)
After that, restart the server and let it run for 24 hours. Then run MySQLTuner again to get new recommendations.
Suggestion to consider for your my.cnf [mysqld] section
These changes will significantly reduce the Maximum possible memory usage of 131 Terabytes calculated by MySQLTuner and reduce CPU Busy when reported by TOP.
Do not blindly increase settings, you are likely to run out of RAM and either be sloooow due to swapping, or even crash.
The “max mem” warning is bogus. There is no accurate formula. Still, it pointed you in the right direction.
mysqltuner has some flaws. Some are quite hard to avoid. (Eg, one thing says to raise xyz, another says to lower it. Which should win?)
If you would like a different analysis, see http://mysql.rjweb.org/doc.php/mysql_analysis