To start with, I'm relatively new to web development.
Under reasonable load (500-700 Q/s) the server is restarting frequently (sometimes every hour), and I get the follow in my syslog each time it happens. I don't get any output to mysql.err or mysql/error.log
This is my first real mysql setup, so I'm sure there is lots that could be improved, but I'm surprised that the server is actually going down so often. The machine has 4GB of ram. Thanks for any suggestions or help!
Ubuntu 10.04, mysql is from the lucid packages.
Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (x86_64) using readline 6.1
Oct 10 01:45:33 host init: mysql main process (1199) terminated with status 1
Oct 10 01:45:33 host init: mysql main process ended, respawning
Oct 10 01:45:42 host /etc/mysql/debian-start[1644]: Upgrading MySQL tables if necessary.
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: Looking for 'mysql' as: /usr/bin/mysql
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Oct 10 01:45:42 host /etc/mysql/debian-start[1648]: This installation of MySQL is already upgraded to 5.1.41, use --force if you still need to run mysql_upgrade
Oct 10 01:45:42 host /etc/mysql/debian-start[1656]: Checking for insecure root accounts.
Oct 10 01:45:43 host /etc/mysql/debian-start[1672]: Triggering myisam-recover for all MyISAM tables
Here's my my.cnf:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
bind-address = host
back_log = 50
max_connections = 100
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = innodb
default-character-set = utf8
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 32M
log-bin=trent-bin
binlog_format=mixed
slow_query_log
long_query_time = 2
server-id = 1
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 2800M
innodb_data_file_path = ibdata1:100M:autoextend
innodb_file_per_table
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout = 50
ssl-ca=/etc/mysql/cacert.pem
ssl-cert=/etc/mysql/server-cert.pem
ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
I have seen mysql behave this way a few times, there are many potential causes.. : to investigatem I would check
1) are there any custom functions that you have written that might be memory leaks? I once saw a median function, custom written on mysql 5, lead to restarts if it was run by two simultaneous queries...
2) if you optimize the tables, does this reduce the restart frequency?
3) are therea ny corrupt tables in the db ?
Related
Schedule for Hour
Daily Schedule
There is a virtual machine installed on the PROXMOX, MySQL is installed there.
For this VM allocated 30GB of RAM and 20 cores because it receives a lot of data.
The problem is that the load on the VM gradually increases, and I do not understand why.
After a reboot MySQL server, the data is processed very quickly, while the load on the RAM in the region of 3-4 GB.
After the server has been running for more than 24 hours, the data starts to be processed for a very long time, while the data arrive in the same amount.
The load on the RAM rises to 25GB.
What's wrong?
I attach a screenshot and my.cnf.
I'm sorry for my bad English.
Thanks for answers.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
skip-name-resolve
event_scheduler = on
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
language = /usr/share/mysql/english
skip-external-locking
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 512K
thread_cache_size = 8
myisam-recover = BACKUP
max_connections = 700
#table_cache = 64
#thread_concurrency = 12
query_cache_limit = 1M
query_cache_size = 50M
innodb_buffer_pool_size = 16G
innodb_buffer_pool_instances = 16
innodb_additional_mem_pool_size=400M
innodb_log_buffer_size=80M
innodb_flush_log_at_trx_commit = 0
innodb_log_file_size = 128M
innodb_flush_method=O_DIRECT
innodb_autoinc_lock_mode = 2
innodb_thread_concurrency = 12
sort_buffer=512M
thread_concurrency=32
#record_buffer=128M
query_cache_type=2
tmp_table_size=1G
general_log_file = /var/log/mysql/mysql.log
general_log = 0
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 10 = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
[mysql]
[isamchk]
key_buffer = 16M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[isamchk]
key_buffer = 16M
Rate Per Second=RPS - Suggestions to consider for your my.cnf [mysqld] section
key_cache_age_threshold=7200 # from 300 seconds to reduce key_reads RPS of 240123
thread_cache_size=100 # from 8 to reduce threads_created in 1 day
innodb_buffer_pool_size=20G # from 16G to reduce innodb_buffer_pool_reads RPS of 20
innodb_read_io_threads=64 # from 1 for improved read performance
innodb_write_io_threads=64 # from 1 for improved write performance
Please get in touch, there are many more opportunities available to improve your instance response time.
Since we are rookies on this, we are having a hard time trying to setup a Wordpress server to support around 200K monthly visiting users. We have two boxes (details below).
The issue here is when the users start accessing the server, MySQL CPU goes to 149%. Here is a copy of the apache2.conf and the mysql.cnf files. Our MySQL database is InnoDB. Any suggestions on how to fix it?
1. Apache Server
Configuration
8 GB Memory / 25 GB Disk + 200 GB / Ubuntu 16.04
apache.conf excerpt
Timeout 40
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 2
2. MySQL Server
Configuration
8 GB Memory / 25 GB Disk + 50 GB / Ubuntu 16.04
my.cnf file
root#mundo-mysql01-c-2-4gib-nyc3-01:/etc/mysql# cat my.cnf
#
# 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/
[mysqld]
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
general_log_file = /var/log/mysql/mysql.log
general_log = 0
# CACHES AND LIMITS #
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048
# MyISAM Settings
max_connections = 300
key_buffer_size = 256M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 16M
thread_cache_size = 32
wait_timeout = 300
connect_timeout = 300
tmp_table_size = 32M
max_heap_table_size = 128M
max_allowed_packet = 128M
max_connect_errors = 10000
read_rnd_buffer_size = 1M
bulk_insert_buffer_size = 1M
query_cache_limit = 4M
query_cache_size = 128M
query_cache_type = 1
query_prealloc_size = 65536
query_alloc_block_size = 131072
low_priority_updates = 1
max_write_lock_count = 1
# * InnoDB
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 256M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 2048M
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 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.
I have an Ubuntu 64-bit system and running Mysql version 5.5.32-0ubuntu0.12.04.1-log. The machine has 64 GB ram.
I have a pretty huge database which almost has 90 GB of data and one table with 250.000.000 rows.
My problem is, that the mysqld process does not take much memory. Just between 2-5 GB. But the memory of the system is fully used for the file cache.
I restarted the server, there were 63 GB memory free. Once I started to execute larger queries, the amount of free memory decreases, while the amount of file cached increases.
So mysql is not loading the data in its RAM, but it uses the file cache.
Queries are very slow. When I query the big table, which - according to explain - uses an index and only has 500.000 rows to consider, it takes minutes.
Do you have any explanation for this phenomen?
Here is my my.cnf. (This is actually the config of my slave, but it shows exactly the same behaviour) My tables are all InnoDB:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
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
bind-address = 127.0.0.1
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
log_error = /var/log/mysql/error.log
server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
[innodb]
innodb_buffer_pool_size = 55G
innodb_log_file_size = 256M
innodb_log_buffer_size = 4M
innodb_flush_log_at_trx_commit=2
innodb_thread_concurrency=0
innodb_file_per_table = 1 # (this is not respected as I changed it after the first database was created). So my ibdata1 file is over 80GB in size
max_connections = 1000 # wenn gleichzeitig viele User zugreifen
table_cache = 10000 # abgeleitet von max_connections, könnte sogar höher sein
tmp_table_size = 5000M # wichtig wg. JOINs, zu kleiner Wert macht die extrem langsam
max_heap_table_size = 5000M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
!includedir /etc/mysql/conf.d/
Increase the key_buffer size to 128M and max_allowed_packet to 128M, as this will speed up the execution of queries
I finally figured out was the problem was. The
innodb_buffer_pool_size = 55G
does not belong in the [innodb] section, but in the [mysqld] section.
All the innodb configs needed to be placed in the mysqld section.