Skip to content

Instantly share code, notes, and snippets.

@fevangelou
Last active Oct 18, 2021
Embed
What would you like to do?
Optimized my.cnf configuration for MySQL/MariaSQL (on cPanel/WHM servers)
# === Optimized my.cnf configuration for MySQL/MariaSQL (on cPanel/WHM servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated February 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
# The settings marked with a specific comment or the word "UPD" (after the value)
# should be adjusted for your system by using database diagnostics tools like:
#
# https://github.com/major/MySQLTuner-perl
# or
# https://github.com/RootService/tuning-primer (supports MySQL up to v5.7)
#
# Run either of these scripts before optimizing your database, at least 1 hr after the optimization & finally
# at least once a day for 3 days (without restarting the database) to see how your server performs and if you need
# to re-adjust anything. The more MySQL/MariaDB runs without restarting, the more usage data it gathers, so these
# diagnostics scripts will report in mode detail how MySQL/MariaDB performs.
#
#
# IMPORTANT NOTE: If there is NO comment after a setting value, then 99,9% of the times you won't need to adjust it.
#
#
# --- THINGS TO DO AFTER YOU UPDATE MY.CNF - TROUBLESHOOTING ---
#
# If any terminal commands are mentioned, make sure you execute them as "root" user.
#
# If MySQL or MariaDB cannot start (or restart), then perform the following actions.
#
# 1. If the server had the stock database configuration and you added or updated any
# "innodb_log_*" settings (as suggested below), then execute these commands ONLY
# the first time you apply this configuration:
#
# $ rm -rvf /var/lib/mysql/ib_logfile*
# $ touch /var/lib/mysql/mysql.sock
# $ touch /var/lib/mysql/mysql.pid
# $ chown -R mysql:mysql /var/lib/mysql
# $ /scripts/restartsrv_mysql
#
# or use the shorthand command:
# $ rm -rvf /var/lib/mysql/ib_logfile*; touch /var/lib/mysql/mysql.sock; touch /var/lib/mysql/mysql.pid; chown -R mysql:mysql /var/lib/mysql; /scripts/restartsrv_mysql
#
# IMPORTANT: If you edit this file from the Engintron WHM app in cPanel/WHM,
# then you DO NOT need to execute the above terminal commands. When you save
# the file through the Engintron WHM app, these terminal commands will be
# executed automatically after the file is saved on disk.
#
# 2. If the setting "bind-address" is not commented out, then make sure the file /etc/hosts is
# properly configured. A good example of a "clean" /etc/hosts file is something like this:
#
# 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
# ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# 1.2.3.4 hostname.domain.tld hostname # <-- Replace accordingly!
#
# Finally restart the database using the related cPanel script:
#
# $ /scripts/restartsrv_mysql
#
# 3. If the database service cannot restart even after the first 2 steps, make sure the database data folder
# (common for either MySQL or MariaDB) "/var/lib/mysql" is owned by the "mysql" user AND group.
# Additionally, the folder itself can have 0751 or 0755 file permissions. To fix it, simply do this:
# $ chown -R mysql:mysql /var/lib/mysql
# $ chmod 0755 /var/lib/mysql
#
# Finally restart the database using the related cPanel script:
#
# $ /scripts/restartsrv_mysql
#
# 4. Adjust SQL settings under "Tweak Settings" in WHM:
# After applying the optimized my.cnf file, you'll also want to DISABLE the following 3 settings
# in the "SQL" tab of Tweak Settings in WHM:
#
# - Allow cPanel & WHM to determine the best value for your MySQL open_files_limit configuration?
# - Allow cPanel & WHM to determine the best value for your MySQL max_allowed_packet configuration?
# - Allow cPanel & WHM to determine the best value for your MySQL innodb_buffer_pool_size configuration?
#
#
# ~ FIN ~
[mysql]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
# === Required Settings ===
basedir = /usr
bind_address = 127.0.0.1 # Change to 0.0.0.0 to allow remote connections
datadir = /var/lib/mysql
max_allowed_packet = 256M
max_connect_errors = 1000000
pid_file = /var/lib/mysql/mysql.pid
port = 3306
skip_external_locking
socket = /var/lib/mysql/mysql.sock
tmpdir = /tmp
user = mysql
# === SQL Compatibility Mode ===
# Enable for b/c with databases created in older MySQL/MariaDB versions
# (e.g. when using null dates)
#sql_mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES
# === InnoDB Settings ===
default_storage_engine = InnoDB
innodb_buffer_pool_instances = 4 # Use 1 instance per 1GB of InnoDB pool size
innodb_buffer_pool_size = 4G # Use up to 70-80% of RAM
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_log_buffer_size = 16M
innodb_log_file_size = 1G
innodb_stats_on_metadata = 0
#innodb_temp_data_file_path = ibtmp1:64M:autoextend:max:20G # Control the maximum size for the ibtmp1 file
#innodb_thread_concurrency = 4 # Optional: Set to the number of CPUs on your system (minus 1 or 2) to better
# contain CPU usage. E.g. if your system has 8 CPUs, try 6 or 7 and check
# the overall load produced by MySQL/MariaDB.
innodb_read_io_threads = 64
innodb_write_io_threads = 64
#innodb_io_capacity = 1000 # Max is 2000
# === MyISAM Settings ===
# The following 3 options are ONLY supported by MariaDB & up to MySQL 5.7
# Do NOT un-comment on MySQL 8.x+
#query_cache_limit = 4M # UPD
#query_cache_size = 64M # UPD
#query_cache_type = 1 # Enabled by default
key_buffer_size = 32M # UPD
low_priority_updates = 1
concurrent_insert = 2
# === Connection Settings ===
max_connections = 100 # UPD - Important: high no. of connections = high RAM consumption
back_log = 512
thread_cache_size = 100
thread_stack = 192K
interactive_timeout = 180
wait_timeout = 180
# For MySQL 5.7+ only (disabled by default)
#max_execution_time = 30000 # Set a timeout limit for SELECT statements (value in milliseconds).
# This option may be useful to address aggressive crawling on large sites,
# but it can also cause issues (e.g. with backups). So use with extreme caution and test!
# More info at: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_execution_time
# For MariaDB 10.1.1+ only (disabled by default)
#max_statement_time = 30 # The equivalent of "max_execution_time" in MySQL 5.7+ (set above)
# The variable is of type double, thus you can use subsecond timeout.
# For example you can use value 0.01 for 10 milliseconds timeout.
# More info at: https://mariadb.com/kb/en/aborting-statements/
# === Buffer Settings ===
innodb_sort_buffer_size = 2M # UPD
join_buffer_size = 4M # UPD
read_buffer_size = 3M # UPD
read_rnd_buffer_size = 4M # UPD
sort_buffer_size = 4M # UPD
# === Table Settings ===
# In systemd managed systems like Ubuntu 16.04+ or CentOS 7+, you need to perform an extra action for table_open_cache & open_files_limit
# to be overriden (also see comment next to open_files_limit).
# E.g. for MySQL 5.7, please check: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
# and for MariaDB check: https://mariadb.com/kb/en/library/systemd/
table_definition_cache = 40000 # UPD
table_open_cache = 40000 # UPD
open_files_limit = 60000 # UPD - This can be 2x to 3x the table_open_cache value or match the system's
# open files limit usually set in /etc/sysctl.conf or /etc/security/limits.conf
# In systemd managed systems this limit must also be set in:
# /etc/systemd/system/mysqld.service.d/override.conf (for MySQL 5.7+) and
# /etc/systemd/system/mariadb.service.d/override.conf (for MariaDB)
max_heap_table_size = 128M
tmp_table_size = 128M
# === Search Settings ===
ft_min_word_len = 3 # Minimum length of words to be indexed for search results
# === Logging ===
log_error = /var/lib/mysql/mysql_error.log
log_queries_not_using_indexes = 1
long_query_time = 5
slow_query_log = 0 # Disabled for production
slow_query_log_file = /var/lib/mysql/mysql_slow.log
[mysqldump]
# Variable reference
# For MySQL 5.7+: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html
# For MariaDB: https://mariadb.com/kb/en/library/mysqldump/
quick
quote_names
max_allowed_packet = 512M
@Friends4U

This comment has been minimized.

Copy link

@Friends4U Friends4U commented Aug 23, 2016

What should I use with 16GB ram and 8 cores?

@brinsleyparagao

This comment has been minimized.

Copy link

@brinsleyparagao brinsleyparagao commented Nov 9, 2016

whats better for: 8 cores / 32g ram / ssd / 1gbps

@ntorga

This comment has been minimized.

Copy link

@ntorga ntorga commented Nov 11, 2016

Nice, but... I think you should consider study more the follow options: "innodb-flush-log-at-trx-commit", "query_cache_limit", "max-heap-table-size", "tmp-table-size", "innodb-log-file-size" & [mysqldump] -> "max-allowed-packet".

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Dec 2, 2016

@ntorga I have, these options are not there randomly...

@Nekkam

This comment has been minimized.

Copy link

@Nekkam Nekkam commented Jan 27, 2017

Great config Fotis i have only one think to comment
query_cache_type = 1 is good only if you use MyISAM . if you use InnoDB query cache is not required ( query_cache_type = 0 ). Moreover query cache harms the speed of overall performance. So it depents on your DB type.

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Jul 15, 2017

@Nekkam Actually, most of the times you'll have lots of MyISAM tables on your DBs. And for that reason, using query cache works miracles. Confirm with Munin and you'll see what I mean. Those preaching that query cache should be off usually refer to servers with 1-2 websites fully controlled and able to work on InnoDB. That's not the case with a typical cPanel hosting scenario.

@chrismfz

This comment has been minimized.

Copy link

@chrismfz chrismfz commented Jul 16, 2017

No point of having "skip-name-resolve" when you already have bind address only localhost. Especially with cPanel, or having a dedicated mysql box.

https://documentation.cpanel.net/pages/viewpage.action?pageId=1507383
"Do not use the skip-name-resolve option in your server's MySQL configuration. This option can cause problems on any server. It will create more problems on remote MySQL servers, during account transfers and restorations, and with phpMyAdmin."

@bscreative

This comment has been minimized.

Copy link

@bscreative bscreative commented Jul 22, 2017

Do these changes also apply to MariaDB?

@screege

This comment has been minimized.

Copy link

@screege screege commented Nov 11, 2017

Do these changes also apply to MariaDB?

Also does anyone recommend changing the swappines to 10 (default is 60)?

@ciscospirit

This comment has been minimized.

Copy link

@ciscospirit ciscospirit commented Feb 24, 2018

Hello,

i have the same question like @screege
Are this settings also valid for mariaDB 10.2 ?

@AWOL-TECH

This comment has been minimized.

Copy link

@AWOL-TECH AWOL-TECH commented Mar 16, 2018

@screege and @ciscospirit yes this should work for Maria DB, if there are any issues it will be logged or shown to you upon restarting the service. - Take a backup

Also yes setting swappines to 10 would be an advantage. It means your server would prefer to use physical RAM over SWAP (until you run out of RAM) just make sure you have plenty swap configured as a backup so you dont crash your server!

@baowesome

This comment has been minimized.

Copy link

@baowesome baowesome commented Apr 3, 2018

@fevangelou can you help me optimizing my vps linux server please sorry i'm new!

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Apr 28, 2018

Updated in April 2018 to include various fixes & improvements.

@codep0et

This comment has been minimized.

Copy link

@codep0et codep0et commented Apr 30, 2018

Hello. If I have a 8 core 32 GB RAM server. Should I simply multiply the values? Since the values are for a 4 core 4gb RAM starting point

Thanks

@frilogg

This comment has been minimized.

Copy link

@frilogg frilogg commented May 1, 2018

Please make a version for a server with 32 gb ram also

@Nirjonadda

This comment has been minimized.

Copy link

@Nirjonadda Nirjonadda commented May 2, 2018

@fevangelou Please what you are recommended for 8 CPUs with 16 GB Ram?

@shigri20

This comment has been minimized.

Copy link

@shigri20 shigri20 commented Jul 9, 2018

I have 10 (hybrid) cpu , 32g ram ... i just used above setting with minor changing in buffer , after that i face bellow mentioned issues :
1- Error failed to start application : could not connect to MySQL server
2- i'm using joomla CMS and cannot login into admin panel
Any suggestion or guide please

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Jul 9, 2018

@shigri20 This means that the connection to the database failed. Make sure the service is up and read the comments at the top of the file very carefully. You probable need to delete your log files so that MySQL can restart with the new configuration.

@malikzubi

This comment has been minimized.

Copy link

@malikzubi malikzubi commented Sep 27, 2018

Hi,
I have 32 Core Cpu and 64gb Ram, Please suggest me the settings accordingly.

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Sep 27, 2018

@malikzubi it depends on many factors e.g. how much RAM you need for other apps, what kind of/how fast storage you have, what type of web app, can you utilize Memcached etc. etc. If you need professional consultation you can always contact me here: https://github.com/engintron/engintron#i-need-commercial-support---do-you-offer-such-services

@siamnews

This comment has been minimized.

Copy link

@siamnews siamnews commented Feb 14, 2019

there is typo it's bind-adress and not bind_adress on line 70. If you don't correct it your mysql server is open to the wicked outside word :)

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Feb 14, 2019

@siamnews It's actually valid https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_bind-address and ironically to your comment it's "address", not "adress".

@mustafaerdinc

This comment has been minimized.

Copy link

@mustafaerdinc mustafaerdinc commented Mar 26, 2019

@fevangelou I have Maria DB 10.3.3 installed. I got this error:

Startup Log:
Mar 26 21:58:54 server.derisnameserver.com mysqld[29223]: 2019-03-26 21:58:54 0 [Warning] Could not increase number of max_open_files to more than 10000 (request: 40135) Mar 26 21:58:54 server.derisnameserver.com mysqld[29223]: 2019-03-26 21:58:54 0 [Warning] Changed limits: max_open_files: 10000 max_connections: 100 (was 100) table_cache: 4935 (was 20000)

and
Log Messages
Mar 26 21:58:54 server mysqld: 2019-03-26 21:58:54 0 [Warning] Changed limits: max_open_files: 10000 max_connections: 100 (was 100) table_cache: 4935 (was 20000) Mar 26 21:58:54 server mysqld: 2019-03-26 21:58:54 0 [Warning] Could not increase number of max_open_files to more than 10000 (request: 40135)

I have created the file blowing:

mkdir /etc/systemd/system/mysqld.service.d

and added:

[Service] LimitNOFILE = 65535

Warning stills there. What may cause this?

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Mar 26, 2019

@mustafaerdinc If you have MariaDB, you should do:

mkdir -p /etc/systemd/system/mariadb.service.d
touch /etc/systemd/system/mariadb.service.d/override.conf
cat > "/etc/systemd/system/mariadb.service.d/override.conf" <<EOF
[Service]
LimitNOFILE=65535
EOF
systemctl daemon-reload
@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Jan 16, 2020

The config has been updated.

Additionally, someone asked what would the right tweaks be for a 64GB RAM / 20 CPU server.

I would adjust the following (from the current config):

innodb_buffer_pool_instances    = 24
innodb_buffer_pool_size         = 24G
innodb_log_file_size            = 1G
innodb_thread_concurrency       = 16
query_cache_limit               = 4M
query_cache_size                = 96M
key_buffer_size                 = 64M

But before doing anything, run a script like https://github.com/major/MySQLTuner-perl or https://github.com/RootService/tuning-primer to see your current usage. Also run the scripts 1hr after the optimization & at least once a day for 3 days (without restarting the database) to see how your server performs and if you need to re-adjust anything. The more MySQL/MariaDB runs without restarting, the more usage data it gathers, so these diagnostics scripts will get you a better view of how MySQL/MariaDB performs.

You'll also want to DISABLE these 3 settings in the "SQL" tab of Tweak Settings in WHM:

Allow cPanel & WHM to determine the best value for your MySQL open_files_limit configuration?
Allow cPanel & WHM to determine the best value for your MySQL max_allowed_packet configuration?
Allow cPanel & WHM to determine the best value for your MySQL innodb_buffer_pool_size configuration?
@EvangelosBalafoutis

This comment has been minimized.

Copy link

@EvangelosBalafoutis EvangelosBalafoutis commented May 18, 2020

I tried the configuration as it is, on a server with 32G ram and 8 Cpus and mysql 5.7x
The mysql cannot restart

The old setup is

[mysqld]
local-infile = 1
default-storage-engine = MyISAM
innodb_file_per_table = 1
performance-schema = 0
sql_mode = no_engine_substitution
max_allowed_packet=268435456
innodb_buffer_pool_size=134217728

Any thought?

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented May 18, 2020

@EvangelosBalafoutis Read the comments at the top of the file please. All of them. The solution is there.

@EvangelosBalafoutis

This comment has been minimized.

Copy link

@EvangelosBalafoutis EvangelosBalafoutis commented May 18, 2020

Hello Fotis.
I tried he steps if mysqldoes not restart and I got the following

[root@sigma etc]# /scripts/restartsrv_mysql
Waiting for “mysql” to restart ……info [restartsrv_mysql] systemd failed to start the service “mysqld” (The “/usr/bin/systemctl restart mysqld.service --no-ask-password” command (process 1084551) reported error number 1 when it ended.): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

…info [restartsrv_mysql] systemd failed to start the service “mysqld” (The “/usr/bin/systemctl restart mysqld.service --no-ask-password” command (process 1084662) reported error number 1 when it ended.): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

…info [restartsrv_mysql] systemd failed to start the service “mysqld” (The “/usr/bin/systemctl restart mysqld.service --no-ask-password” command (process 1084780) reported error number 1 when it ended.): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

…failed.

Cpanel::Exception::Services::StartError
Service Status
mysqld (/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid) is running as mysql with PID 90503 (systemd+/proc check method).

Service Error
(XID p73q5q) The “mysql” service failed to start.

Startup Log
May 19 00:52:49 sigma.omicronacademy.com systemd[1]: Starting MySQL Server...

Log Messages
2020-05-18T21:52:48.384713Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-05-18T21:52:44.259651Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
2020-05-18T21:52:40.371393Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented May 19, 2020

Run systemctl status mysqld.service to see why MySQL won't start. If there is no practical hint there, see MySQL's error log.

In any case, make sure the contents of this my.cnf are properly copied into your server's /etc/my.cnf file.

@EvangelosBalafoutis

This comment has been minimized.

Copy link

@EvangelosBalafoutis EvangelosBalafoutis commented May 19, 2020

Hello Fotis.
The file is properly copied. I tried on another server with no problem to restart.
Because I had mysql down I return to the old my.cnf.

But mmy error log says

2020-05-18T22:39:27.121991Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:27.122710Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2020-05-18T22:39:28.435750Z 0 [Warning] Could not increase number of max_open_files to more than 50000 (request: 80110)
2020-05-18T22:39:28.435948Z 0 [Warning] Changed limits: table_open_cache: 24945 (requested 40000)
2020-05-18T22:39:28.598329Z 0 [Note] libgovernor.so found
2020-05-18T22:39:28.598350Z 0 [Note] All governors functions found too
2020-05-18T22:39:28.598384Z 0 [Note] Governor connected
2020-05-18T22:39:28.598388Z 0 [Note] All governors lve functions found too
2020-05-18T22:39:28.598695Z 0 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --slow-query-log is not set
2020-05-18T22:39:28.598700Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-18T22:39:28.598705Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2020-05-18T22:39:28.599674Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-cll-lve) starting as process 1108942 ...
2020-05-18T22:39:28.603292Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-18T22:39:28.603317Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-18T22:39:28.603321Z 0 [Note] InnoDB: Uses event mutexes
2020-05-18T22:39:28.603324Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-18T22:39:28.603327Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-18T22:39:28.603329Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-18T22:39:28.603503Z 0 [Note] InnoDB: Number of pools: 1
2020-05-18T22:39:28.603583Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-18T22:39:28.629156Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2020-05-18T22:39:28.629174Z 0 [Warning] InnoDB: io_setup() attempt 1.
2020-05-18T22:39:29.129267Z 0 [Warning] InnoDB: io_setup() attempt 2.
2020-05-18T22:39:29.629363Z 0 [Warning] InnoDB: io_setup() attempt 3.
2020-05-18T22:39:30.129474Z 0 [Warning] InnoDB: io_setup() attempt 4.
2020-05-18T22:39:30.629602Z 0 [Warning] InnoDB: io_setup() attempt 5.
2020-05-18T22:39:31.129723Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2020-05-18T22:39:31.129751Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2020-05-18T22:39:31.130257Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2020-05-18T22:39:31.130274Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-18T22:39:31.130282Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-18T22:39:31.130287Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-18T22:39:31.130293Z 0 [ERROR] Failed to initialize builtin plugins.
2020-05-18T22:39:31.130297Z 0 [ERROR] Aborting

2020-05-18T22:39:31.130318Z 0 [Note] Binlog end
2020-05-18T22:39:31.130399Z 0 [Note] Shutting down plugin 'CSV'
2020-05-18T22:39:31.130410Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:31.131464Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2020-05-18T22:39:32.431097Z 0 [Warning] Could not increase number of max_open_files to more than 50000 (request: 80110)
2020-05-18T22:39:32.431252Z 0 [Warning] Changed limits: table_open_cache: 24945 (requested 40000)
2020-05-18T22:39:32.588494Z 0 [Note] libgovernor.so found
2020-05-18T22:39:32.588515Z 0 [Note] All governors functions found too
2020-05-18T22:39:32.588550Z 0 [Note] Governor connected
2020-05-18T22:39:32.588554Z 0 [Note] All governors lve functions found too
2020-05-18T22:39:32.588858Z 0 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --slow-query-log is not set
2020-05-18T22:39:32.588862Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-18T22:39:32.588868Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2020-05-18T22:39:32.589848Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-cll-lve) starting as process 1108988 ...
2020-05-18T22:39:32.593669Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-18T22:39:32.593689Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-18T22:39:32.593693Z 0 [Note] InnoDB: Uses event mutexes
2020-05-18T22:39:32.593698Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-18T22:39:32.593701Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-18T22:39:32.593704Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-18T22:39:32.593894Z 0 [Note] InnoDB: Number of pools: 1
2020-05-18T22:39:32.593984Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-18T22:39:32.620481Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2020-05-18T22:39:32.620500Z 0 [Warning] InnoDB: io_setup() attempt 1.
2020-05-18T22:39:33.120626Z 0 [Warning] InnoDB: io_setup() attempt 2.
2020-05-18T22:39:33.620740Z 0 [Warning] InnoDB: io_setup() attempt 3.
2020-05-18T22:39:34.120842Z 0 [Warning] InnoDB: io_setup() attempt 4.
2020-05-18T22:39:34.620919Z 0 [Warning] InnoDB: io_setup() attempt 5.
2020-05-18T22:39:35.121029Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2020-05-18T22:39:35.121039Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2020-05-18T22:39:35.121400Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2020-05-18T22:39:35.121408Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-18T22:39:35.121413Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-18T22:39:35.121417Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-18T22:39:35.121421Z 0 [ERROR] Failed to initialize builtin plugins.
2020-05-18T22:39:35.121423Z 0 [ERROR] Aborting

2020-05-18T22:39:35.121437Z 0 [Note] Binlog end
2020-05-18T22:39:35.121492Z 0 [Note] Shutting down plugin 'CSV'
2020-05-18T22:39:35.121498Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:35.122266Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2020-05-18T22:39:36.439434Z 0 [Warning] Could not increase number of max_open_files to more than 50000 (request: 80110)
2020-05-18T22:39:36.439590Z 0 [Warning] Changed limits: table_open_cache: 24945 (requested 40000)
2020-05-18T22:39:36.598534Z 0 [Note] libgovernor.so found
2020-05-18T22:39:36.598555Z 0 [Note] All governors functions found too
2020-05-18T22:39:36.598592Z 0 [Note] Governor connected
2020-05-18T22:39:36.598596Z 0 [Note] All governors lve functions found too
2020-05-18T22:39:36.598953Z 0 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --slow-query-log is not set
2020-05-18T22:39:36.598957Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-18T22:39:36.598963Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2020-05-18T22:39:36.599938Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-cll-lve) starting as process 1109023 ...
2020-05-18T22:39:36.603630Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-18T22:39:36.603653Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-18T22:39:36.603657Z 0 [Note] InnoDB: Uses event mutexes
2020-05-18T22:39:36.603662Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-18T22:39:36.603665Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-18T22:39:36.603668Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-18T22:39:36.603841Z 0 [Note] InnoDB: Number of pools: 1
2020-05-18T22:39:36.603944Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-18T22:39:36.628651Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2020-05-18T22:39:36.628672Z 0 [Warning] InnoDB: io_setup() attempt 1.
2020-05-18T22:39:37.128780Z 0 [Warning] InnoDB: io_setup() attempt 2.
2020-05-18T22:39:37.628892Z 0 [Warning] InnoDB: io_setup() attempt 3.
2020-05-18T22:39:38.129025Z 0 [Warning] InnoDB: io_setup() attempt 4.
2020-05-18T22:39:38.629111Z 0 [Warning] InnoDB: io_setup() attempt 5.
2020-05-18T22:39:39.129214Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2020-05-18T22:39:39.129227Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2020-05-18T22:39:39.129601Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2020-05-18T22:39:39.129609Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-18T22:39:39.129615Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-18T22:39:39.129619Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-18T22:39:39.129623Z 0 [ERROR] Failed to initialize builtin plugins.
2020-05-18T22:39:39.129625Z 0 [ERROR] Aborting

2020-05-18T22:39:39.129644Z 0 [Note] Binlog end
2020-05-18T22:39:39.129689Z 0 [Note] Shutting down plugin 'CSV'
2020-05-18T22:39:39.129695Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:39.130426Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2020-05-18T22:39:40.428814Z 0 [Warning] Could not increase number of max_open_files to more than 50000 (request: 80110)
2020-05-18T22:39:40.429004Z 0 [Warning] Changed limits: table_open_cache: 24945 (requested 40000)
2020-05-18T22:39:40.588371Z 0 [Note] libgovernor.so found
2020-05-18T22:39:40.588393Z 0 [Note] All governors functions found too
2020-05-18T22:39:40.588427Z 0 [Note] Governor connected
2020-05-18T22:39:40.588431Z 0 [Note] All governors lve functions found too
2020-05-18T22:39:40.588735Z 0 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --slow-query-log is not set
2020-05-18T22:39:40.588739Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-18T22:39:40.588745Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2020-05-18T22:39:40.589742Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-cll-lve) starting as process 1109081 ...
2020-05-18T22:39:40.593523Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-18T22:39:40.593546Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-18T22:39:40.593550Z 0 [Note] InnoDB: Uses event mutexes
2020-05-18T22:39:40.593553Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-18T22:39:40.593557Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-18T22:39:40.593560Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-18T22:39:40.593727Z 0 [Note] InnoDB: Number of pools: 1
2020-05-18T22:39:40.593805Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-18T22:39:40.620202Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2020-05-18T22:39:40.620220Z 0 [Warning] InnoDB: io_setup() attempt 1.
2020-05-18T22:39:41.120328Z 0 [Warning] InnoDB: io_setup() attempt 2.
2020-05-18T22:39:41.620456Z 0 [Warning] InnoDB: io_setup() attempt 3.
2020-05-18T22:39:42.120598Z 0 [Warning] InnoDB: io_setup() attempt 4.
2020-05-18T22:39:42.620718Z 0 [Warning] InnoDB: io_setup() attempt 5.
2020-05-18T22:39:43.120849Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2020-05-18T22:39:43.120866Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2020-05-18T22:39:43.121237Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2020-05-18T22:39:43.121248Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-18T22:39:43.121254Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-18T22:39:43.121257Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-18T22:39:43.121261Z 0 [ERROR] Failed to initialize builtin plugins.
2020-05-18T22:39:43.121264Z 0 [ERROR] Aborting

2020-05-18T22:39:43.121278Z 0 [Note] Binlog end
2020-05-18T22:39:43.121321Z 0 [Note] Shutting down plugin 'CSV'
2020-05-18T22:39:43.121338Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:43.122104Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2020-05-18T22:39:44.430237Z 0 [Warning] Could not increase number of max_open_files to more than 50000 (request: 80110)
2020-05-18T22:39:44.430391Z 0 [Warning] Changed limits: table_open_cache: 24945 (requested 40000)
2020-05-18T22:39:44.588306Z 0 [Note] libgovernor.so found
2020-05-18T22:39:44.588328Z 0 [Note] All governors functions found too
2020-05-18T22:39:44.588363Z 0 [Note] Governor connected
2020-05-18T22:39:44.588367Z 0 [Note] All governors lve functions found too
2020-05-18T22:39:44.588673Z 0 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --slow-query-log is not set
2020-05-18T22:39:44.588677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-18T22:39:44.588683Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2020-05-18T22:39:44.589669Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-cll-lve) starting as process 1109129 ...
2020-05-18T22:39:44.593358Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-18T22:39:44.593382Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-18T22:39:44.593385Z 0 [Note] InnoDB: Uses event mutexes
2020-05-18T22:39:44.593388Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-18T22:39:44.593391Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-18T22:39:44.593394Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-18T22:39:44.593562Z 0 [Note] InnoDB: Number of pools: 1
2020-05-18T22:39:44.593641Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-18T22:39:44.620025Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2020-05-18T22:39:44.620046Z 0 [Warning] InnoDB: io_setup() attempt 1.
2020-05-18T22:39:45.120147Z 0 [Warning] InnoDB: io_setup() attempt 2.
2020-05-18T22:39:45.620277Z 0 [Warning] InnoDB: io_setup() attempt 3.
2020-05-18T22:39:46.120412Z 0 [Warning] InnoDB: io_setup() attempt 4.
2020-05-18T22:39:46.620542Z 0 [Warning] InnoDB: io_setup() attempt 5.
2020-05-18T22:39:47.120657Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2020-05-18T22:39:47.120668Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2020-05-18T22:39:47.121029Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2020-05-18T22:39:47.121038Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-18T22:39:47.121044Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-18T22:39:47.121047Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-18T22:39:47.121051Z 0 [ERROR] Failed to initialize builtin plugins.
2020-05-18T22:39:47.121054Z 0 [ERROR] Aborting

2020-05-18T22:39:47.121067Z 0 [Note] Binlog end
2020-05-18T22:39:47.121111Z 0 [Note] Shutting down plugin 'CSV'
2020-05-18T22:39:47.121118Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:47.121808Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2020-05-18T22:39:48.431640Z 0 [Warning] Could not increase number of max_open_files to more than 50000 (request: 80110)
2020-05-18T22:39:48.431795Z 0 [Warning] Changed limits: table_open_cache: 24945 (requested 40000)
2020-05-18T22:39:48.588549Z 0 [Note] libgovernor.so found
2020-05-18T22:39:48.588570Z 0 [Note] All governors functions found too
2020-05-18T22:39:48.588605Z 0 [Note] Governor connected
2020-05-18T22:39:48.588609Z 0 [Note] All governors lve functions found too
2020-05-18T22:39:48.588923Z 0 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --slow-query-log is not set
2020-05-18T22:39:48.588928Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-18T22:39:48.588933Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2020-05-18T22:39:48.589908Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-cll-lve) starting as process 1109169 ...
2020-05-18T22:39:48.593632Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-18T22:39:48.593658Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-18T22:39:48.593661Z 0 [Note] InnoDB: Uses event mutexes
2020-05-18T22:39:48.593664Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-18T22:39:48.593667Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-18T22:39:48.593670Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-18T22:39:48.593843Z 0 [Note] InnoDB: Number of pools: 1
2020-05-18T22:39:48.593948Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-18T22:39:48.619840Z 0 [Warning] InnoDB: io_setup() failed with EAGAIN. Will make 5 attempts before giving up.
2020-05-18T22:39:48.619863Z 0 [Warning] InnoDB: io_setup() attempt 1.
2020-05-18T22:39:49.119916Z 0 [Warning] InnoDB: io_setup() attempt 2.
2020-05-18T22:39:49.620033Z 0 [Warning] InnoDB: io_setup() attempt 3.
2020-05-18T22:39:50.120145Z 0 [Warning] InnoDB: io_setup() attempt 4.
2020-05-18T22:39:50.620255Z 0 [Warning] InnoDB: io_setup() attempt 5.
2020-05-18T22:39:51.120368Z 0 [ERROR] InnoDB: io_setup() failed with EAGAIN after 5 attempts.
2020-05-18T22:39:51.120379Z 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2020-05-18T22:39:51.120748Z 0 [ERROR] InnoDB: Cannot initialize AIO sub-system
2020-05-18T22:39:51.120757Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-05-18T22:39:51.120763Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-18T22:39:51.120767Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-18T22:39:51.120771Z 0 [ERROR] Failed to initialize builtin plugins.
2020-05-18T22:39:51.120773Z 0 [ERROR] Aborting

2020-05-18T22:39:51.120788Z 0 [Note] Binlog end
2020-05-18T22:39:51.120831Z 0 [Note] Shutting down plugin 'CSV'
2020-05-18T22:39:51.120847Z 0 [Note] Shutting down plugin 'MyISAM'
2020-05-18T22:39:51.121623Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
@EvangelosBalafoutis

This comment has been minimized.

Copy link

@EvangelosBalafoutis EvangelosBalafoutis commented May 21, 2020

Hello Fotis. I removed every line had to do with innodb and it did restarted if this make sence.
I removed

# InnoDB Settings
default_storage_engine          = InnoDB
innodb_buffer_pool_instances    = 2     # Use 1 instance per 1GB of InnoDB pool size
innodb_buffer_pool_size         = 2G    # Use up to 70-80% of RAM
innodb_file_per_table           = 1
innodb_flush_log_at_trx_commit  = 0
innodb_flush_method             = O_DIRECT
innodb_log_buffer_size          = 16M
innodb_log_file_size            = 512M
innodb_stats_on_metadata        = 0

#innodb_temp_data_file_path     = ibtmp1:64M:autoextend:max:20G # Control the maximum size for the ibtmp1 file
#innodb_thread_concurrency      = 7     # Optional: Set to the number of CPUs on your system (minus 1 or 2) to better
                                        # contain CPU usage. E.g. if your system has 8 CPUs, try 6 or 7 and check
                                        # the overall load produced by MySQL/MariaDB.
innodb_read_io_threads          = 64
innodb_write_io_threads         = 64
@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented May 22, 2020

@EvangelosBalafoutis This is not a solution though... Seeing the logs that you sent, it's most likely you have limits enforced by MySQL Governor (by CloudLinux). For the record, unless your server hosts 300+ accounts, you probably don't need CloudLinux. And hey, if MySQL Governor worked, you wouldn't be looking to optimize MySQL, right? Food for thought...

@EvangelosBalafoutis

This comment has been minimized.

Copy link

@EvangelosBalafoutis EvangelosBalafoutis commented May 22, 2020

Thank you for the info Fotis, Ill think about asking the client to remove it.

@EvangelosBalafoutis

This comment has been minimized.

Copy link

@EvangelosBalafoutis EvangelosBalafoutis commented May 22, 2020

Or I'll try with completely remove mysql govenor and let you know. Thank you my friend.

@darnellkeithj

This comment has been minimized.

Copy link

@darnellkeithj darnellkeithj commented Nov 11, 2020

Cant do anything on wp site without mysql and php-fpm using 60% or higher cpu. What is causing this? Here is my.cnf

[mysql]
port                            = 3306
socket                          = /var/lib/mysql/mysql.sock

[mysqld]
# Required Settings
basedir                         = /usr
bind_address                    = 0.0.0.0 # Change to 0.0.0.0 to allow remote connections
datadir                         = /var/lib/mysql
max_allowed_packet              = 16M
max_connect_errors              = 1000000
pid_file                        = /var/lib/mysql/mysql.pid
port                            = 3306
skip_external_locking
socket                          = /var/lib/mysql/mysql.sock
tmpdir                          = /tmp
user                            = mysql
performance_schema              = ON
skip-name-resolve
# to pinpoint aborted connection we need this:
log-warnings=2

# InnoDB Settings
default_storage_engine          = InnoDB
innodb_buffer_pool_instances    = 4     # Use 1 instance per 1GB of InnoDB pool size
innodb_buffer_pool_size         = 4G    # Use up to 70-80% of RAM
innodb_file_per_table           = On
innodb_flush_log_at_trx_commit  = 2
innodb_flush_method             = O_DIRECT
innodb_log_buffer_size          = 8M
innodb_log_file_size            = 512M
innodb_stats_on_metadata        = 0

#innodb_temp_data_file_path     = ibtmp1:3G:autoextend # Control the maximum size for the ibtmp1 file
innodb_thread_concurrency      = 0    # Optional: Set to the number of CPUs on your system (minus 1 or 2) to better
                                        # contain CPU usage. E.g. if your system has 8 CPUs, try 6 or 7 and check
                                        # the overall load produced by MySQL/MariaDB.
innodb_read_io_threads          = 128
innodb_write_io_threads         = 128
innodb_use_native_aio           = 0

# MyISAM Settings
query_cache_limit               = 4M    # UPD - Option supported by MariaDB & up to MySQL 5.7, remove this line on MySQL 8.x
query_cache_size                = 0   # UPD - Option supported by MariaDB & up to MySQL 5.7, remove this line on MySQL 8.x
query_cache_type                = 0     # Option supported by MariaDB & up to MySQL 5.7, remove this line on MySQL 8.x

#key_buffer_size                 = 32M   # UPD

low_priority_updates            = 1
concurrent_insert               = 2

# Connection Settings
max_connections                 = 200   # UPD - Important: high no. of connections = more RAM consumption

back_log                        = 512
thread_cache_size               = 100
thread_stack                    = 192K

interactive_timeout             = 300
wait_timeout                    = 300

# For MySQL 5.7+ only (disabled by default)
#max_execution_time             = 30000 # Set a timeout limit for SELECT statements (value in milliseconds).
                                        # This option may be useful to address aggressive crawling on large sites,
                                        # but it can also cause issues (e.g. with backups). So use with extreme caution and test!
                                        # More info at: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_execution_time

# For MariaDB 10.1.1+ only (disabled by default)
#max_statement_time             = 30    # The equivalent of "max_execution_time" in MySQL 5.7+ (set above)
                                        # The variable is of type double, thus you can use subsecond timeout.
                                        # For example you can use value 0.01 for 10 milliseconds timeout.
                                        # More info at: https://mariadb.com/kb/en/aborting-statements/

# Buffer Settings
#join_buffer_size                = 4M    # UPD
#read_buffer_size                = 3M    # UPD
#read_rnd_buffer_size            = 4M    # UPD
#sort_buffer_size                = 4M    # UPD

# Table Settings
# In systemd managed systems like CentOS 7, you need to perform an extra action for table_open_cache & open_files_limit
# to be overriden (also see comment next to open_files_limit).
# E.g. for MySQL 5.7 (when it's supported in cPanel), please check: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
# and for MariaDB check: https://mariadb.com/kb/en/library/systemd/
table_definition_cache          = 40000 # UPD
table_open_cache                = 40000 # UPD
open_files_limit                = 60000 # UPD - This can be 2x to 3x the table_open_cache value or match the system's
                                        # open files limit usually set in /etc/sysctl.conf or /etc/security/limits.conf
                                        # In systemd managed systems this limit must also be set in:
                                        # /etc/systemd/system/mysqld.service.d/override.conf (for MySQL 5.7+) and
                                        # /etc/systemd/system/mariadb.service.d/override.conf (for MariaDB)

max_heap_table_size             = 126M
tmp_table_size                  = 128M

# Search Settings
ft_min_word_len                 = 3     # Minimum length of words to be indexed for search results

# Logging
log_error                       = /var/lib/mysql/mysql_error.log
log_queries_not_using_indexes   = 1
long_query_time                 = 5
slow_query_log                  = 0     # Disabled for production
slow_query_log_file             = /var/lib/mysql/mysql_slow.log

[mysqldump]
# Variable reference
# For MySQL 5.7: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html
# For MariaDB:   https://mariadb.com/kb/en/library/mysqldump/
quick
quote_names
max_allowed_packet              = 64M
@fevangelou

This comment has been minimized.

Copy link
Owner Author

@fevangelou fevangelou commented Nov 13, 2020

@darnellkeithj It's really way off. You are increasing some variables to irrational values (e.g. max_connections, innodb_*_io_threads -which should not exceed 64- and others) and commenting out variables (e,g, *_buffer_size) which are important. You should seek professional performance auditing (which extends beyond MySQL/MariaDB). If you need my services you can always email me at engintron [at] gmail [dot] com.

@NanbanRaj

This comment has been minimized.

Copy link

@NanbanRaj NanbanRaj commented Dec 2, 2020

I have Intel Xeon E3-1230 v2 - 3.3 GHz - 4 core(s) 8 threads.
RAM: 16GB - DDR3

Hello @fevangelou can you suggest me the my.cnf file. Really i am confused lot about this configuration.

@karimrattani

This comment has been minimized.

Copy link

@karimrattani karimrattani commented Jan 23, 2021

Thanks for the config, I had to change below config otherwise MySQL failed to restart
innodb_read_io_threads = 40
innodb_write_io_threads = 40

@locksmithunit

This comment has been minimized.

Copy link

@locksmithunit locksmithunit commented Mar 5, 2021

is because you have 40 cores 4M 8C like mine.
i did that 16. just in case, is not good to read everything from the DISK anyway.

the only thing I little bit confused about.
is this:
innodb_io_capacity = 1000

https://dev.mysql.com/doc/refman/8.0/en/innodb-configuring-io-capacity.html

this very good but it depends on your drive.
in this case, I dont know what they talking about if you have Linux.
they recommended 1000 as well.

innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity = 1000

This can be very good to cPanel on a VPS cloud 4M 8C
BUT YOU MUST SPEAK WITH YOUR HOSTING ASK THEM IF IS SSD OR SATA 2 WITH 7200RPM

If they hosting with SSD (Must of the VPS hosting with SSD)
so need to uncomment the io_capacitiy = 1000

This 16M 8C is not what must of the hosting selling today...
I think is be better to improve the old version of the 4M 8C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment