mysql 超100%cpu排查

后台top查看进程

top - 10:23:21 up 152 days, 7 min,  2 users,  load average: 7.69, 7.86, 6.69
Tasks: 114 total,   2 running, 112 sleeping,   0 stopped,   0 zombie
%Cpu(s): 55.7 us,  0.2 sy,  0.0 ni, 44.0 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8010172 total,   399032 free,  1592428 used,  6018712 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  6088608 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                             
 1444 mysql     20   0 3790108 754032   6592 S 221.9  9.4   1886:15 mysqld                                                              

登录数据库,并查看当前是否有语句执行慢

[xxxx@VM_0_2_centos ~]$ mysql -u xxxx -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2108
Server version: 5.7.22-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show full processlist;

手动复制对应语句直接进行执行(确认是否因为此数据查询慢)

1 row in set (3.07 sec)

对查询慢语句进行添加索引等处理,再检查执行

1 row in set (0.00 sec)
发布了43 篇原创文章 · 获赞 24 · 访问量 42万+

猜你喜欢

转载自blog.csdn.net/u012700515/article/details/104043579