蜘蛛服务器崩溃的网站

我有一个服务器,让我的MySQL服务器已经消失/连接超时/连接拒绝错误,当它被抓取。 在服务器上有很多用户的情况下,它在高峰时期似乎也减慢了很多。 我在这台服务器上安装了Magento Enterprise。 我想知道这可能是持久连接的问题,或者可能是我的一些设置在my.conf中的一些错误?

以下是我的服务器上的一些信息:

Processor #1 Vendor GenuineIntel Name QEMU Virtual CPU version (cpu64-rhel6) Speed 2127.998 MHz Cache 4096 KB Processor #2 Vendor GenuineIntel Name QEMU Virtual CPU version (cpu64-rhel6) Speed 2127.998 MHz Cache 4096 KB Processor #3 Vendor GenuineIntel Name QEMU Virtual CPU version (cpu64-rhel6) Speed 2127.998 MHz Cache 4096 KB Processor #4 Vendor GenuineIntel Name QEMU Virtual CPU version (cpu64-rhel6) Speed 2127.998 MHz Cache 4096 KB RAM 10GB HDD 200GB 

这是我的my.conf:

 [mysqld] thread_concurrency=4 thread_cache_size=64 wait_timeout = 400 table_cache=2048 query_cache_type=1 query_cache_size=512M query_cache_limit=512M key_buffer_size=256M max_allowed_packet=32M max_connections=1000 tmp_table_size=1024M max_heap_table_size=1024M table_definition_cache=4000 table_open_cache=4000 open_files_limit=65535 sort_buffer_size=1M read_buffer_size=1M join_buffer_size=16M innodb_thread_concurrency=0 innodb_file_per_table=1 innodb_buffer_pool_size=4G innodb_lock_wait_timeout=300 innodb_flush_log_at_trx_commit=1 innodb_additional_mem_pool_size=24M tmpdir=/mysqltmp log_error=/var/log/mysql/mysql-error.log log_queries_not_using_indexes=1 slow_query_log_file=/var/lib/mysql/mysql-slow.log 

在发生这些错误时,服务器资源如下(来自Munin):

 CPU = 395% RAM (apps) = approx 6gb I/O Stat (read/write) = approx -10k/10k 

看起来蜘蛛超载你。 使用mysqltuner来检查你的mysqlconfiguration。

configuration您的数据库,使其不会占用超过60%的系统RAM。

根据您发布的最新信息,减less:

query_cache_size =(我会以64M开头)

query_cache_limit =(我会以1M开头)

wait_timeout = 400? 把这个值等于你的apache超时时间,并考虑一个用户等待300秒为你服务他们的响应;)(我会开始把mysql和apache都下降到30秒)。

如果你有很多表(特别是myisam),请增加open_files_limit ,不要忘记你的系统limits.conf

如果降低缓冲区没有帮助,你可以限制蜘蛛与iptables 🙂