项目报错:出现大量的mysql连接错误
Next yiidbException: SQLSTATE[HY000] [2002] 连接超时 in /srv/www/vendor/yiisoft/yii2/db/Connection.php:624 Stack trace: #0 /srv/www/vendor/yiisoft/yii2/db/Connection.php(996): yiidbConnection->open() #1 /srv/www/vendor/yiisoft/yii2/db/Connection.php(983): yiidbConnection->getMasterPdo() #2 /srv/www/vendor/yiisoft/yii2/db/Command.php(253): yiidbConnection->getSlavePdo() #3 /srv/www/vendor/yiisoft/yii2/db/Command.php(1143): yiidbCommand->prepare(true) #4 /srv/www/vendor/yiisoft/yii2/db/Command.php(425): yiidbCommand->queryInternal('fetchColumn', 0) #5 /srv/www/vendor/yiisoft/yii2/db/Query.php(463): yiidbCommand->queryScalar() #6 /srv/www/vendor/yiisoft/yii2/db/ActiveQuery.php(340): yiidbQuery->queryScalar('COUNT(*)', Object(yiidbConnection))
分析:
(1)由此可以看到,整个服务的根源在于mysql出现了问题,一般可能就是瞬间的高并发,慢查询sql增多,导致mysql直接宕机,整个服务崩溃
(2)可以看到,mysql的qps瞬间增大,cpu直接打满,mysql慢查询次数增加