0

I've used WHM's (cPanel) to optimize the mysql configuration on my server and it suggested making the following changes which I made

innodb_buffer_pool_size=3328M
key_buffer_size=55M
innodb_log_file_size=832M
max_heap_table_size=320M
tmp_table_size=320M
join_buffer_size=1M

I've then ran mysqltuner.pl and it contradicted some of the tuning made by WHM/cPanel so I'm not sure which optimizer is "correct"

MySQL Tuner Output

[OK] Currently running supported MySQL version 10.6.12-MariaDB-cll-lve
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/lib/mysql/hosting.err exists
[--] Log file: /var/lib/mysql/hosting..err (1M)
[OK] Log file /var/lib/mysql/hosting.err is not empty
[OK] Log file /var/lib/mysql/hosting.err is smaller than 32 Mb
[OK] Log file /var/lib/mysql/hosting..err is readable.
[!!] /var/lib/mysql/hosting.err contains 2314 warning(s).
[!!] /var/lib/mysql/hosting.err contains 466 error(s).
[--] 2 start(s) detected in /var/lib/mysql/hosting.err
[--] 1) 2023-04-02 14:25:04 0 [Note] /usr/sbin/mariadbd: ready for connections.
[--] 2) 2023-04-02 12:25:04 0 [Note] /usr/sbin/mariadbd: ready for connections.
[--] 2 shutdown(s) detected in /var/lib/mysql/hosting..err
[--] 1) 2023-04-02 14:25:03 0 [Note] /usr/sbin/mariadbd: Shutdown complete
[--] 2) 2023-04-02 12:25:03 0 [Note] /usr/sbin/mariadbd: Shutdown complete

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in MyISAM tables: 352.6M (Tables: 574)
[--] Data in MEMORY tables: 0B (Tables: 147)
[--] Data in InnoDB tables: 28.3G (Tables: 19665)
[--] Data in Aria tables: 32.0K (Tables: 1)
[!!] Total fragmented tables: 1

-------- 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] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[--] There are 620 basic passwords in the list.

-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 3d 15h 6m 39s (40M q [128.218 qps], 503K conn, TX: 217G, RX: 26G)
[--] Reads / Writes: 63% / 37%
[--] Binary logging is disabled
[--] Physical Memory     : 31.2G
[--] Max MySQL memory    : 42.3G
[--] Other process memory: 0B
[--] Total buffers: 3.8G global + 259.7M per thread (151 max threads)
[--] Performance_schema Max memory usage: 277M
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 42.6G (136.43% of installed RAM)
[!!] Maximum possible memory usage: 42.3G (135.62% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (3/40M)
[!!] Highest connection usage: 100% (152/151)
[OK] Aborted connections: 0.39% (1965/503236)
[!!] 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: 0% (227 temp sorts / 4M sorts)
[!!] Joins performed without indexes: 5196
[!!] Temporary tables created on disk: 60% (2M on disk / 3M total)
[OK] Thread cache hit rate: 99% (153 created / 503K connections)
[OK] Table cache hit rate: 92% (39M hits / 42M requests)
[!!] table_definition_cache (400) is less than number of tables (20760)
[OK] Open file limit used: 0% (43/43K)
[OK] Table locks acquired immediately: 99% (1M immediate / 1M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance_schema is activated.
[--] Memory used by Performance_schema: 278.0M
[--] Sys schema is installed.

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

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.5% (10.2M used / 55.0M cache)
[OK] Key buffer size / total MyISAM indexes: 55.0M/53.5M
[OK] Read Key buffer hit rate: 99.7% (5M cached / 16K reads)
[!!] Write Key buffer hit rate: 42.1% (438K cached / 184K writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 3.2G / 28.3G
[OK] Ratio InnoDB log file size / InnoDB Buffer pool size: 832.0M * 1/3.2G should be equal to 25%
[--] Number of InnoDB Buffer Pool Chunk: 26 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: 99.93% (6053164495 hits / 6057203875 total)
[!!] InnoDB Write Log efficiency: 1236.93% (10607318 hits / 857552 total)
[OK] InnoDB log waits: 0.00% (0 waits / 11464870 writes)

-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/480.0K
[OK] Aria pagecache hit rate: 96.3% (45M cached / 1M 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:
    Check warning line(s) in /var/lib/mysql/hosting.err file
    Check error line(s) in /var/lib/mysql/hosting.err file
    Run ALTER TABLE ... FORCE or OPTIMIZE TABLE to defragment tables for better performance
      ALTER TABLE `luvocoma_luvotesting`.`wp_posts` FORCE; -- can free 13 MiB
    Total freed space after defragmentation : 13 MiB
    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).
    Temporary table size is already large: reduce result set size
    Reduce your SELECT DISTINCT queries without LIMIT clauses
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 (> 1.0M, or always use indexes with JOINs)
    table_definition_cache (400) > 20760 or -1 (autosizing if supported)
    key_buffer_size (~ 10M)
    innodb_buffer_pool_size (>= 28.3G) if possible.

Some of my thoughts

The vast majority of the errors in the hosting.err file are:

[Warning] Access denied for user 'root'@'localhost' (using password: NO)

[Warning] Access denied for user 'Cpanel::MysqlUtils::Unprivileged'@'localhost' (using password: NO)

[Warning] Aborted connection 721 to db: 'unconnected' user: 'Cpanel::MysqlUtils::Unprivileged' host: 'localhost' (Got an error writing communication packets)

Only for a few lines later it suggesting:

Variables to adjust:

skip-name-resolve=0

My current my.cnf

[client-server]
!includedir /etc/my.cnf.d

[mysqld]
log-error = /var/lib/mysql/hosting.err
performance-schema = 0
innodb_file_per_table = 1
unix_socket = OFF
innodb_buffer_pool_size=3328M
max_allowed_packet = 268435456
bind-address=127.0.0.1

key_buffer_size=55M
innodb_log_file_size=832M
max_heap_table_size=320M
tmp_table_size=320M
join_buffer_size=1M
general_log_file="/var/lib/mysql/hosting.log"
slow_query_log_file="/var/lib/mysql/hosting-slow.log"
#skip-name-resolve=1

Today I've updated the settings to change the following:

join_buffer_size=320M
max_connections = 200
innodb_buffer_pool_size=8192M
slow_query_log=1

Server Details:

  • The server has 16 vCPU, 32GB RAM and 450GB of disk storage. It has a 4GB swap setup.
  • AlmaLinux 8 (CloudLinux 8)
  • WHM / cPanel
  • CloudLinux
  • MariaDB 10.6 with CloudLinux MySQL Governor
  • LiteSpeed Web Server
  • The cPanel accounts have WordPress websites with mostly guest views as there are no user registrations

I'd greatly appreciate some thoughts and suggestions, hopefully no one sees any obvious misconfigurations on my part!

I'm hoping the genius of @Rick James can assist with some of his knowledge! :D

1
  • 1
    A MySQL tuner results from "Up for: 16s " that small an uptime is rather meaningless. Try after 1hr preferably about 12hrs. A show global status for a raw information comparison would be valuable to link to.
    – danblack
    Mar 28 at 8:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.