为什么我的mysql运行这个命令并吃了很多我的cpu(55 - 120%)我已经尝试了一切.显示进程,并优化我的所有查询,慢查询日志,增加缓冲大小.
我也一遍又一遍地杀了这个过程,但它一直在运行.这个命令做什么用的?为什么我的mysql在我的服务器中吃了很多我的cpu?我无法追踪高CPU使用率的原因.
命令:
/usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/srv1.myserver.com.err --pid-file=/var/lib/mysql/srv1.myserver.com.pid
ursitesion.. 5
有许多因素会影响数据库性能.这个问题没有直接的解决方案.包括硬件和软件在内的多种因素对此负责.以下几点需要考虑:
应用程序的高用户负载
DB服务器的硬件配置较低或不兼容(处理器,内存,SWAP文件大小等)
数据库服务器配置不正确
使用Teamquest等工具检查系统性能,并观察用户数量的CPU使用情况.在特定时间段内找出系统中正确的用户数.使用以下命令
SELECT username, count(username) FROM session_table_of_application WHERE 1 GROUP BY username;
可以在CPU使用率变高时找到最大用户数.
您还应该检查该期间的内存使用情况.Teamquest也会帮助你.运行[MySQL Tuner][2]
以查找MySQL设置中的不匹配.
运行以下命令以检查全局状态:
select * from information_schema.GLOBAL_STATUS
运行以下命令检查以下重要的系统变量:
show variables like 'innodb_buffer_pool_size';
show variables like 'innodb_flush_log_at_trx_commit';
show variables like 'innodb_open_files';
show variables like 'innodb_table_locks';
show variables like 'innodb_thread_concurrency';
show variables like 'join_buffer_size';
show variables like 'key_buffer_size';
show variables like 'max_connections';
show variables like 'max_delayed_threads';
show variables like 'max_heap_table_size';
show variables like 'max_tmp_tables';
show variables like 'thread_cache_size';
show variables like 'tmp_table_size';
show variables like 'wait_timeout';
show variables like 'myisam_sort_buffer_size';
有可能存在一些利用大量CPU资源的查询.因此,您必须检查在此期间运行的查询列表.运行以下命令:
SELECT HOST,COMMAND,TIME,INFO FROM INFORMATION_SCHEMA.PROCESSLIST where command !='sleep' and time>10 and command !='Binlog Dump' order by TIME desc;
分析您的所有观察结果,然后只有您会找到此问题的原因.可能是硬件负责或需要更正MySQL系统变量.
有许多因素会影响数据库性能.这个问题没有直接的解决方案.包括硬件和软件在内的多种因素对此负责.以下几点需要考虑:
应用程序的高用户负载
DB服务器的硬件配置较低或不兼容(处理器,内存,SWAP文件大小等)
数据库服务器配置不正确
使用Teamquest等工具检查系统性能,并观察用户数量的CPU使用情况.在特定时间段内找出系统中正确的用户数.使用以下命令
SELECT username, count(username) FROM session_table_of_application WHERE 1 GROUP BY username;
可以在CPU使用率变高时找到最大用户数.
您还应该检查该期间的内存使用情况.Teamquest也会帮助你.运行[MySQL Tuner][2]
以查找MySQL设置中的不匹配.
运行以下命令以检查全局状态:
select * from information_schema.GLOBAL_STATUS
运行以下命令检查以下重要的系统变量:
show variables like 'innodb_buffer_pool_size';
show variables like 'innodb_flush_log_at_trx_commit';
show variables like 'innodb_open_files';
show variables like 'innodb_table_locks';
show variables like 'innodb_thread_concurrency';
show variables like 'join_buffer_size';
show variables like 'key_buffer_size';
show variables like 'max_connections';
show variables like 'max_delayed_threads';
show variables like 'max_heap_table_size';
show variables like 'max_tmp_tables';
show variables like 'thread_cache_size';
show variables like 'tmp_table_size';
show variables like 'wait_timeout';
show variables like 'myisam_sort_buffer_size';
有可能存在一些利用大量CPU资源的查询.因此,您必须检查在此期间运行的查询列表.运行以下命令:
SELECT HOST,COMMAND,TIME,INFO FROM INFORMATION_SCHEMA.PROCESSLIST where command !='sleep' and time>10 and command !='Binlog Dump' order by TIME desc;
分析您的所有观察结果,然后只有您会找到此问题的原因.可能是硬件负责或需要更正MySQL系统变量.