MySQL专用服务器上的高CPU

我们有一个prestashop网站运行在10K产品的专用服务器上,我有慢的性能,看着htop发现,MySQL的CPU是100%。

专用服务器

CPU:Intel(R)Xeon(R)CPU E3-1230 V2 @ 3.30GHz

内存:16 GB

MySQL的:

innodb_file_per_table max_connections=500 max_user_connections=300 wait_timeout=100 interactive-timeout=100 table_open_cache=1024 thread_cache_size=64 join_buffer=16M sort_buffer=32M table_open_cache=5000 key_buffer_size=512M innodb_buffer_pool_size=2GB sort_buffer_size=8M read_buffer_size=8M read_rnd_buffer_size=8M myisam_sort_buffer_size=128M max_allowed_packet=32M net_retry_count=512 thread_cache=8 thread_concurrency=32 server_id=1 collation_server=utf8_unicode_ci character_set_server=utf8 tmp_table_size=128M max_heap_table_size=128M query_cache_limit=256K query_cache_size=100MB query_cache_type=1 concurrent_insert=2 low_priority_updates=1 open_files_limit=50000 default-storage-engine=MyISAM slow_query_log [mysqldump] quick max_allowed_packet=16M 

什么需要configuration/更改以获得更好的性能? 谢谢

请检查当前的mysql进程是什么,当有连接到mysql服务器的应用程序出现错误时,有时候mysql服务会占用很多资源。

很难说你应该改变哪些设置,以及你应该改变它们。 看来你正在使用默认的configuration设置,这可能不适合你的服务器。

MySQLTuner是一个开始进行调查的好地方,它是一个stream行的脚本,您可以运行它并查看当前的configuration并提出改进build议。

https://github.com/major/MySQLTuner-perl

另一个有用的工具是慢查询日志。 你可以看到哪些查询需要很长时间才能运行,可能写得不好。

如果您的Web服务器也在同一台服务器上运行,那么不要过分强调您的MySQLcaching设置,繁忙的stream量可能会导致服务器内存不足,并开始分页,这将使您死在水中。

以下build议需要您的研究,每天只实施一个项目。 有些可能会dynamic应用。 build议[mysqld}节cfg / ini值跟着,可以修改,添加或删除。

 join_buffer=16M REMOVE, not a valid name sort_buffer=32M REMOVE, not a valid name thread_cache=8 REMOVE, not a valid name sort_buffer_size=8M REMOVE to allow default of 2MB to work for you read_buffer_size=8M REMOVE to allow default of 128K to work for you read_rnd_buffer_size=8M REMOVE to allow default of 256K to work for you 

最后3将提高用户的响应时间(通过最小化读取开销),并显着减less你的MySQL RAM的足迹。 使用MySQLCalculator.com将帮助你明白为什么/如何。

如需详细分析,请在完整工作日之后,在您的原始问题中发布以下内容,

 SHOW GLOBAL STATUS; SHOW GLOBAL VARIABLES; SHOW ENGINE INNODB STATUS; 

对于其他特定的configurationbuild议,每天要应用一个监视器。