我们的服务器上有一个大问题,它托管了大约十个 magento 网站。我做了所有明显的优化,比如 Opcode 的 APC、缓存后端的 APC、innodb 设置调整、magento 编译等。
网站加载正常,但有时,一天会有 5-6 次 MySQL 查询“COMMIT”阻塞 MySQL 服务器并花费很长时间执行(> 500 秒)。然后随着所有新传入连接,服务器满载并出现错误“连接过多”。
出现问题时,phpmyadmin的截图如下:http://imagesia.com/process_2l0n
我的 my.cnf(没有第一个默认部分)
#
# * Fine Tuning
#
key_buffer = 384M
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 = 2048
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_type = 1
query_cache_limit = 1M
query_cache_size = 64M
#
# * 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
log_error = /var/log/mysql/error.log
# Here you can see queries with especially long duration
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 5
#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
#
# * 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 = 1024M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_flush_method=O_DIRECT
#
# * 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
# limite à partir de laquelle les tables temporaires sont créées sur le DD
tmp_table_size=128M
max_heap_table_size=128M
有任何想法吗 ?
感谢您的帮助。
答案1
我在强大实用程序 MySQLtuner 的帮助下对 MySQL 进行了许多优化,现在问题已经解决。