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?
Related
Hi are trying to optimize MySQL for a huge traffic web server, we are using Apache 2.4 , and MySQL 5.6 version.
We have put these parameters in MySQL configuration file
cat /etc/my.cnf
[mysqld]
skip-external-locking
key_buffer = 500M
max_allowed_packet=64M
max_connections = 2000
max_user_connections = 50000
wait_timeout=180
connect_timeout=120
table_open_cache=4096
table_definition_cache=4096
myisam_sort_buffer_size = 64M
thread_cache_size = 128
query_cache_size = 190M
query_cache_limit = 3M
open_files_limit=10000
log_error = /var/log/mysql/error.log
default-storage-engine=MyISAM
[mysqld]
log-bin=mysql-bin
binlog-do-db=******
server-id=1
[mysql]
no-auto-rehash
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
replicate-do-db=*****
auto_increment_increment = 2
auto_increment_offset = 1
replicate-same-server-id = 0
slave-skip-errors=all
[mysqld]
slave-skip-errors=1062
skip-slave-start
query_cache_type=1
[mysqld]
innodb_lock_wait_timeout=120
slave_compressed_protocol=1
query_cache_size = 190M
The QC is inefficient when it is big; limit to about 50M.
slave-skip-errors=1062
This is a flavor of "sweeping bugs under the rug".
default-storage-engine=MyISAM
passé.
key_buffer = 500M
If you do stick with MyISAM, and this server is running just MySQL, then use 1000M.
server-id=1
Make sure each server has a different value.
But that is only configuration. If you have slow queries, let's see them and try to improve them.
i create a my.cnf file with mysqltuner but mysql not started with it,
and i get every time connection refused in my wordpress.
this is my my.cnf file
[mysqld]
#user = mysql
#default-storage-engine = InnoDB
wait_timeout = 8
connect_timeout = 20
interactive_timeout=5
key-buffer-size=32M
myisam-recover=FORCE,BACKUP
thread_concurrency=8
max-allowed-packet=16M
max-connect-errors=1000000
datadir="/var/lib/mysql/"
# CACHES AND LIMITS #
tmp-table-size=512M
join_buffer_size =2G
max-heap-table-size=512M
query_cache_size = 512M
query-cache-type=ON
query_cache_limit=104857
max-connections=120
thread-cache-size=65
open-files-limit=65535
table-definition-cache=4096
table-open-cache=102400
log_slow_queries = /var/log/mysql/mysql-slow.log
# INNODB #
innodb-flush-method=O_DIRECT
innodb-log-files-in-group=2
#innodb-log-file-size = 16M
innodb-flush-log-at-trx-commit=1
innodb-file-per-table=1
innodb-buffer-pool-size=512G
innodb_buffer_pool_instances=16
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqldump]
quick
max_allowed_packet=500M
when i change my.cnf file to my old it work but problem steel not solved.
can anyone help me whats wrong in my.cnf file.
i solve problem by change my.cnf file to below code, thanks for your tips
[mysqld]
#user = mysql
#default-storage-engine = InnoDB
key-buffer-size=32M
myisam-recover=FORCE,BACKUP
thread_concurrency=8
max-allowed-packet=16M
max-connect-errors=1000000
datadir="/var/lib/mysql/"
# CACHES AND LIMITS #
tmp-table-size=512M
max-heap-table-size=512M
query-cache-type=ON
query-cache-size=8MB
query_cache_limit=104857
max-connections=650
thread-cache-size=65
open-files-limit=65535
table-definition-cache=4096
table-open-cache=102400
# INNODB #
innodb-flush-method=O_DIRECT
innodb-log-files-in-group=2
#innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit=1
innodb-file-per-table=1
innodb-buffer-pool-size=16G
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqldump]
quick
max_allowed_packet=500M
Operation failed:
Couldn't find section [mysqld] in the config file /etc/mysql/my.cnf
It is with this error, what is it and how do I fix?
I followed the link : https://bugs.mysql.com/bug.php?id=50030
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id = 1
# Uncomment the following if you want to log updates
#log-bin=mysql-bin
# binary logging format - mixed recommended
#binlog_format=mixed
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout
It means MySQL Workbench is looking for a [mysqld] section in your my.cnf file. It's standard to have one, so I suggest adding one. My test shows Workbench will add this for you, so I'm not sure why it's not for you, but ultimately the solution is to add it.
I don't really know how to make the best performance for my mysql (mariadb) server with editing the my.cnf config file. I changed the values on the basis of the sample my-huge.ini. I think this is not the best options with my server.
Configuration:
2x Intel Xeon CPU 3.00GHz (+hyper threading)
4GB RAM
2x scsi hdd 300gb (mirror)
I prefer MyISAM because my application can reach the best performace with that.
My server based for running mysql so I really want to make it good :)
Query statistics: 65% select, 30% update
Can someone suggest me a really good configuration?
There is a method or software which can make a benchmark from my server and suggest me what kind of options need I change?
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 4
# Error log - should be very few entries.
log_error = /var/log/mysql/error.log
# Here you can see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#slow_query_log = 1
#long_query_time = 2
#log_queries_not_using_indexes
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
I have a problem with my WampServer 2.5. MySQL 5.6.16 consumes 500 mb RAM memory. I have no databases, fresh installation. I set table_definition_cache = 400 in my.ini, but this does not solve the problem. This is my.ini
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[wampmysqld]
port = 3306
socket = /tmp/mysql.sock
key_buffer_size = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
table_definition_cache = 400
performance_schema=off
basedir=c:/wamp/bin/mysql/mysql5.6.17
log-error=c:/wamp/logs/mysql.log
datadir=c:/wamp/bin/mysql/mysql5.6.17/data
lc-messages-dir=c:/wamp/bin/mysql/mysql5.6.17/share
# Change your locale here !
lc-messages=fr_FR
# Avoid warning
explicit_defaults_for_timestamp = TRUE
# Disable Federated by default
skip-federated
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
# New for MySQL 5.6 if no slave
skip-slave-start
# Point the following paths to different dedicated disks
#tmpdir = /tmp/
#log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\mysql\data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\mysql\data/
#innodb_log_arch_dir = C:\mysql\data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld]
port=3306
explicit_defaults_for_timestamp = TRUE
It seems like you may have already seen an answer suggesting this change and the change is a good idea, but :-
Did you install the 64bit WAMPServer?
If you did there was a tiny bug that got through testing on the 64bit version of WAMPServer.
In the 64bit version of WAMPServer the name of the MySQL service was changed to wampmysqld64 but they forgot to change the section name in the my.ini file accordingly.
So in my.ini change the section name to
# The MySQL server
[wampmysqld64]
The way MySQL works is to look at its own service name and then look in the my.ini for configuration setting under a section heading that matches its service name.
This should make MySQL pay attention to your config changes.