Can Anyone Help me to put the Best Setting for MySQL my.cnf configuration. I have never modified the WHM default my.cnf setting. I am using CentOS WHM(cPanel).
Right Now Every time I Add/Update Posts MySQL CPU load gets into peak and it gets down after 3-5 minutes. I also did database optimization via phpMyAdmin. I have like no knowledge in MySQL that's why I need your help. Thank You in advance.
- MyCPU - Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
- Total Processors: 24
- RAM - 24GB
my.cnf Config
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
performance-schema=0
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
innodb_buffer_pool_size=26214400
max_allowed_packet=268435456
open_files_limit=40000
innodb_file_per_table=1
mysqltuner.pl
>> MySQLTuner 2.0.7
* Jean-Marie Renouard <[email protected]>
* Major Hayden <[email protected]>
>> Bug reports, feature requests, and downloads at http://mysqltuner.pl/
>> Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.7.39
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mysqld.log exists
[--] Log file: /var/log/mysqld.log (1M)
[OK] Log file /var/log/mysqld.log is not empty
[OK] Log file /var/log/mysqld.log is smaller than 32 Mb
[OK] Log file /var/log/mysqld.log is readable.
[!!] /var/log/mysqld.log contains 1226 warning(s).
[!!] /var/log/mysqld.log contains 4494 error(s).
[--] 13 start(s) detected in /var/log/mysqld.log
[--] 1) 2022-07-26T06:19:40.139514Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 2) 2022-07-26T06:19:31.781074Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 3) 2022-06-22T06:18:34.436714Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 4) 2022-06-13T17:32:41.391135Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 5) 2022-05-20T06:20:53.227443Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 6) 2022-04-28T06:23:10.156350Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 7) 2022-04-26T06:19:36.293205Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 8) 2022-04-26T06:19:27.053465Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 9) 2022-02-11T04:11:16.610287Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 10) 2022-02-09T05:10:52.845046Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 11 shutdown(s) detected in /var/log/mysqld.log
[--] 1) 2022-07-26T06:19:39.477939Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 2) 2022-07-26T06:19:30.590977Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 3) 2022-06-22T06:18:33.049031Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 4) 2022-05-20T06:20:51.192314Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 5) 2022-04-28T06:22:53.450673Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 6) 2022-04-26T06:19:35.698012Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 7) 2022-04-26T06:19:26.078360Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 8) 2022-02-11T04:11:15.723668Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 9) 2022-02-09T05:10:52.081450Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 10) 2022-02-08T20:25:03.836241Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: ARCHIVE BLACKHOLE CSV -FEDERATED InnoDB MEMORY MRG_MYISAM MyISAM PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 291.8M (Tables: 267)
[--] Data in InnoDB tables: 2.5G (Tables: 760)
[OK] Total fragmented tables: 0
-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
-------- Views Metrics -----------------------------------------------------------------------------
-------- Triggers Metrics --------------------------------------------------------------------------
-------- Routines Metrics --------------------------------------------------------------------------
-------- Security Recommendations ------------------------------------------------------------------
[OK] No Role user detected
[OK] There are no anonymous accounts for any database users
[!!] User ''erroriope'@'server.localhost.com'' has no password set.
[!!] There is no basic password file list!
-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 53d 0h 35m 4s (1B q [403.841 qps], 21M conn, TX: 28622G, RX: 221G)
[--] Reads / Writes: 97% / 3%
[--] Binary logging is disabled
[--] Physical Memory : 23.4G
[--] Max MySQL memory : 38.0G
[--] Other process memory: 0B
[--] Total buffers: 66.0M global 257.1M per thread (151 max threads)
[--] Performance_schema Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 38.2G (163.12% of installed RAM)
[!!] Maximum possible memory usage: 38.0G (162.05% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/1B)
[!!] Highest connection usage: 100% (152/151)
[OK] Aborted connections: 0.02% (5215/21398314)
[!!] CPanel and Flex system skip-name-resolve should be on
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 1% (4M temp sorts / 225M sorts)
[!!] Joins performed without indexes: 756362
[!!] Temporary tables created on disk: 51% (105M on disk / 206M total)
[OK] Thread cache hit rate: 99% (119K created / 21M connections)
[OK] Table cache hit rate: 99% (2B hits / 2B requests)
[OK] table_definition_cache (1400) is greater than number of tables (1307)
[OK] Open file limit used: 1% (501/40K)
[OK] Table locks acquired immediately: 99% (279M immediate / 279M locks)
-------- Performance schema ------------------------------------------------------------------------
[!!] Performance_schema should be activated.
[--] Sys schema is installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.
-------- MyISAM Metrics ----------------------------------------------------------------------------
[OK] Key buffer used: 100.0% (8.0M used / 8.0M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/70.9M
[OK] Read Key buffer hit rate: 99.6% (14B cached / 54M reads)
[!!] Write Key buffer hit rate: 89.1% (1M cached / 976K writes)
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 25.0M / 2.5G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (384%): 48.0M * 2 / 25.0M should be equal to 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk: 1 for 1 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: 98.47% (347419925689 hits/ 352826132195 total)
[!!] InnoDB Write Log efficiency: 60.07% (56677143 hits/ 94358371 total)
[OK] InnoDB log waits: 0.00% (0 waits / 37681228 writes)
-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine not available.
-------- 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: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Check warning line(s) in /var/log/mysqld.log file
Check error line(s) in /var/log/mysqld.log file
Set up a Secure Password for 'erroriope'@'server.localhost.com' user: SET PASSWORD FOR 'erroriope'@'server.localhost.com' = PASSWORD('secure_password');
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Reduce or eliminate persistent connections to reduce connection usage
name resolution is enabled due to cPanel doesn't support this disabled.
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).
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read this:
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
max_connections (> 151)
wait_timeout (< 28800)
interactive_timeout (< 28800)
skip-name-resolve=0
join_buffer_size (> 256.0K, or always use indexes with JOINs)
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
performance_schema=ON
innodb_buffer_pool_size (>= 2.5G) if possible.
innodb_log_file_size should be (=3M) if possible, so InnoDB total log files size equals 25% of buffer pool size.
CodePudding user response:
- Rarely is config the place to start when you have CPU problems.
- However, in your case
innodb_buffer_pool_size=26214400
is terrible. Was there some reason for lowering the already too-low default? Change it to 15G. - For hight CPU, look at the slow queries to see what can be improved.
- Since WP is involved, this will help some with speed: WP Index Improvements