在随机时间(不取决于网站的流量),mysql更新卡住了。我们使用MySQL 5.5.46-0+deb8u1 - (Debian)
然后将其更改为:Percona Server version: 5.5.47-37.7-log - Percona Server (GPL), Release 37.7, Revision 764f304
并且问题相同。
横幅统计表的结构
CREATE TABLE `banner_stat` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`banner_id` int(11) NOT NULL,
`appear` int(11) NOT NULL,
`click` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `banner_id` (`banner_id`),
KEY `date` (`date`)
) ENGINE=InnoDB AUTO_INCREMENT=6289 DEFAULT CHARSET=latin1
我们的mysql配置:
[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
#
expire_logs_days=2
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
skip-host-cache
skip-name-resolve
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = *.*.*.*
#
# * Fine Tuning
#
tmp_table_size = 256M
max_heap_table_size = 256M
sort_buffer_size = 8M
read_buffer_size = 8M
join_buffer_size = 12M
key_buffer_size = 400M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 128K
#query_cache_min_res_unit = 2k
query_cache_type = 1
query_cache_size = 45M
#query_cache_limit = 0
#query_cache_size = 0
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# 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 = 1
#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
max_binlog_size = 100M
binlog_do_db = binlog
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
innodb_buffer_pool_size = 160M
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
#max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[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/
我们正在使用4芯和1芯带Debian OS的8GB ram服务器。
如果你知道导致这个问题的原因,或者你知道我们如何解决它,请写下来。
答案 0 :(得分:1)
你的innodb配置部分有点空。我认为您的数据库的默认设置是不够的。试试这个:
innodb_buffer_pool_size = 5000M
innodb_buffer_pool_instances = 8
innodb_log_file_size = 100M
innodb_log_buffer_size = 10M
innodb_flush_log_at_trx_commit = 2