Optimal my.cnf recommendation - mysql

I'd like to ask anyone with a bit of experience on an opinion of my current my.cnf settings and what optimizations should be done.
Server specs are:
CPU: AMD Opteron™ 3280, 8 Cores, 8x 2.4 GHz
RAM: 16 GB DDR3
2x 2,000 GB SATA II-HDD, 7.2k - RAID 1 Software
Cloudlinux + Cpanel installed
Apache + Mysql 5.5 + NginxCP + eAccelerator
The current my.cnf file is:
[client]
port=3306
socket="/var/lib/mysql/mysql.sock"
[mysqld]
innodb_additional_mem_pool_size=16M
innodb_buffer_pool_size=10G
innodb_file_per_table=1
innodb_log_buffer_size=4M
innodb_flush_log_at_trx_commit=2
log-bin=mysql-bin
myisam_sort_buffer_size=64M
expire_logs_days=7
query_cache_size=128M
thread_cache_size=12
max_allowed_packet=15M
skip-federated
table_definition_cache=2048
local-infile=0
table_cache=8192
max_connections=60
read_buffer_size=2M
slow_query_log=1
slow_query_log_file="/var/log/slow_queries.log"
thread_concurrency=16
sort_buffer_size=2M
port=3306
join_buffer_size=16M
key_buffer_size=600M
query_cache_limit=10M
socket="/var/lib/mysql/mysql.sock"
skip-external-locking
query-cache-type=1
long_query_time=5
default-storage-engine=InnoDB
tmp_table_size=384M
max_heap_table_size=384M
[myisamchk]
read_buffer=2M
key_buffer=256M
sort_buffer_size=256M
write_buffer=2M
[mysqldump]
max_allowed_packet=16M

DBAs recommended to use the Percona Wizard first o all https://tools.percona.com/wizard
Secondly follow this guide: http://www.percona.com/blog/2014/01/28/10-mysql-settings-to-tune-after-installation/

Related

question about mysql parameter max_connections

1.below is mysql config fule, /db/mysql/app/mysql/my.cnf
we set max_connections=4000
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
port=3306
socket=/db/mysql/data/mysqltmp/mysql.sock
[mysqld]
basedir=/db/mysql/app/mysql
datadir=/db/mysql/data/mydata
tmpdir=/db/mysql/data/mydata/tmp
bind-address=10.200.212.67
port=3306
wait_timeout=86400
server_id=2
user=mysql
socket=/db/mysql/data/mysqltmp/mysql.sock
skip-name-resolve
lower_case_table_names=1
default-storage-engine=InnoDB
max_heap_table_size=32M
thread_stack = 512K
key_buffer_size=256M
sort_buffer_size=2M
join_buffer_size=2M
innodb_file_per_table=1
innodb_open_files=2048
back_log=1000
max_connections=4000
open_files_limit=65535
table_open_cache=128
log_bin=mysql-bin
binlog_format=MIXED
expire_logs_days=7
log_error=/db/mysql/data/mydata/mysql-error.log
pid-file=/db/mysql/app/mysql/mysql.pid
slow_query_log=1
long_query_time=2
slow_query_log_file=/db/mysql/data/mydata/mysql-slow.log
max_allowed_packet=256M
binlog_cache_size=2M
innodb_buffer_pool_size = 8192M
innodb_write_io_threads=4
innodb_read_io_threads=4
innodb_thread_concurrency=0
innodb_purge_threads=1
innodb_flush_log_at_trx_commit=2
innodb_log_buffer_size=64M
innodb_log_file_size=512M
innodb_log_files_in_group=3
innodb_lock_wait_timeout=7200
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
gtid-mode=ON
enforce_gtid_consistency=1
log-slave-updates=1
2.when we do some application ,in rush hours ,
In addition, during the problem period of MySQL, the maximum number of connections is less than 1000, and the db max_connections setting is 4000
and when the connection is to 1000, the application will report timeout 30000ms. so app connet failed ,.
3.the quesiton is if there are any other hidden restrictions that cause the connection not allowed to more than 1000?

Extermly high MySQL CPU%

Any advice how to solve this problem? this is a new dedicated machine, the MySQL CPU usage strikes to 300% CPU usage
the command:
/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
[mysqld]
bind-address=127.0.0.1
performance-schema=0
init-connect='SET NAMES utf8mb4'
collation_server=utf8mb4_unicode_ci
character_set_server=utf8mb4
skip-character-set-client-handshake
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
innodb_buffer_pool_size=134217728
max_allowed_packet=268435456
open_files_limit=10000
innodb_file_per_table=1
slow_query_log=1
slow_query_log_file="/var/log/mysql-slow.log"
long_query_time = 2
machine is: Intel Xeon E3-1246V3, HDD SATA 2TB, 32GB DDR3
Centos 7.7, CPANEL installed

How increase mysql query if include query " . - / ' etc

How can i improve mysql query if include point, comma etc..
My data size is 3GB and 12,000,000 row.
My System Information
Time of this report: 4/20/2018, 13:55:16
Operating System: Windows Server 2008 R2 Standard 64-bit (6.1, Build 7600) (7600.win7_gdr.120401-1505)
Language: Turkish (Regional Setting: Turkish)
System Manufacturer: VMware, Inc.
System Model: VMware Virtual Platform
BIOS: PhoenixBIOS 4.0 Release 6.0
Processor: Intel(R) Xeon(R) CPU E3-1245 V2 # 3.40GHz (8 CPUs), ~3.4GHz
Memory: 16384MB RAM
Available OS Memory: 16384MB RAM
Page File: 8402MB used, 24362MB available
Windows Dir: C:\Windows
DirectX Version: DirectX 11
DX Setup Parameters: Not found
User DPI Setting: Using System DPI
System DPI Setting: 96 DPI (100 percent)
DWM DPI Scaling: Disabled
DxDiag Version: 6.01.7600.16385 32bit Unicode
MY.ini file is:
[client]
port=3306
[mysql]
no-beep=
[mysqld]
port=3306
datadir=C:/ProgramData/MySQL/MySQL Server 5.7/Data
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
log-output=FILE
general-log=0
general_log_file="WIN-FFJIGKKSAPK.log"
slow-query-log=1
slow_query_log_file="WIN-FFJIGKKSAPK-slow.log"
long_query_time=10
log-error="WIN-FFJIGKKSAPK.err"
server-id=1
secure-file-priv="C:/ProgramData/MySQL/MySQL Server 5.7/Uploads"
max_connections = 2000
query_cache_size = 0
table_open_cache=39390
open_files_limit=78780
tmp_table_size = 20M
thread_cache_size = 100
myisam_max_sort_file_size=100G
myisam_sort_buffer_size = 64M
key_buffer_size = 32M
read_buffer_size=64K
read_rnd_buffer_size=256K
innodb_flush_log_at_trx_commit = 0
innodb_log_buffer_size=8M
innodb_buffer_pool_size = 6000M
innodb_log_file_size = 256M
innodb_thread_concurrency=0
innodb_autoextend_increment=64
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_io_capacity=500
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=256K
max_allowed_packet = 16M
query_cache_type=0
sort_buffer_size=256K
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
ft_min_word_len = 3
max_connect_errors = 1000000
expire_logs_days = 14
max_heap_table_size = 32M
myisam-recover-options = FORCE
slave-net-timeout = 60
sync_binlog = 1
skip-name-resolve
please help me i want to speed up mysql queries. thank you

cpu usage is extremly high (1800%) due to mysql

I am having a 4 GB vps box. At any time there are not more than 40 visitors browsing 10-15 page simultaneously. Suddenly 2 days back server cpu usage touching almost 2000%. Strange thing is when i stop the apache, it still does not go down. below is the top command result.
PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND
23644 mysql 15 0 12.7g 742m 6840 S 1812.0 18.1 1107:15 mysqld
14076 xyzaz 19 0 194m 16m 7348 S 7.1 0.4 0:00.22 php
14080 xyzaz 18 0 195m 17m 7276 S 6.5 0.4 0:00.20 php
i have troubleshooted every thing but no luck. I dont know it was working fine but suddenly how it changed to such a high value.
below is the output of my.cnf
[mysqld]
local-infile=0
max_connections=500
key_buffer_size=128M
myisam_sort_buffer_size=64M
join_buffer_size=2M
read_buffer_size=1M
sort_buffer_size=2M
max_heap_table_size=16M
table_cache=1800
thread_cache_size=384
interactive_timeout=25
wait_timeout=7200
connect_timeout=10
max_allowed_packet=268435456
max_connect_errors=100
query_cache_limit=4M
query_cache_size=128M
query_cache_type=1
tmp_table_size=64M
skip-name-resolve
innodb_buffer_pool_size=229M
default-storage-engine=MyISAM
innodb_file_per_table=1
[mysqld_safe]
open_files_limit = 6553
[mysqldump]
quick
max_allowed_packet=16M
[myisamchk]
key_buffer_size=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
Any help is really appriciated

How should I config the my.ini(or my.cnf) file for mysql?

Thanks for taking your time to look at my question, and I hope that you can help me with this.
I have a Windows Server 2012 server, it has:
Memory : 3840MB Ram
Processor: Intel(R) Xeon(R) CPU E5-2680 v2 # 2.80GHz (2 CPUs), ~2.8GHz
But still mysql is going up to 100% cpu usage
I ran the MySQLInstanceConfig.exe configuration Wizard to help me config everything for mysql and this is the my.ini config file that it created:
[client]
port=3306
[mysql]
default-character-set=latin1
[mysqld]
The TCP/IP Port the MySQL Server will listen on
port=3306
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/data/"
character-set-server=latin1
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=100
query_cache_size=0
table_cache=256
tmp_table_size=192M
thread_cache_size=8
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=384M
key_buffer_size=332M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K
* INNODB Specific options *
innodb_additional_mem_pool_size=14M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=7M
innodb_buffer_pool_size=643M
innodb_log_file_size=65M
innodb_thread_concurrency=8
But Something is still wrong, it's taking to much CPU
Try to use given configuration. This might help you.
[client]
port=3306
[mysql]
default-character-set=latin1
[mysqld]
The TCP/IP Port the MySQL Server will listen on
port=3306
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/data/" #put basedir and datadir on different location
character-set-server=latin1
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=100
query_cache_size=10M
query_cache_limit=15M
table_cache=256
tmp_table_size=100M # Reduce temp table size it uses ram
thread_cache_size=16 #Increase this value
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=384M
key_buffer_size=250M #Reduce this
read_buffer_size=64K read_rnd_buffer_size=256K
sort_buffer_size=256K
* INNODB Specific options *
innodb_additional_mem_pool_size=14M # SHOW INNODB STATUS will display the current amount used. set according to that
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=5M
innodb_buffer_pool_size=512M
innodb_log_file_size=65M
innodb_thread_concurrency=8