在使用jmeter压测mysql性能时报出下面的错误信息:

Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)

出现这个问题的原因在于max_connections(mysql最大连接数)设置的较小(仅有151),连接数超过max_connections就会导致客户端获取不到数据库连接,所以调整下max_connections的值即可:

set global  max_connections = 10000  --暂时先调整为10000,具体应用时要根据需求对应调整

因为笔者模仿的是并发1000的查询,所以10000的连接完全满足需求。

压测结果如下所示:

jmeter压测mysql Cannot create PoolableConnectionFactory (Could not create connection to database serv

从上图可以看到对应查询对应mysql的TPS在1000左右,需要注意的是笔者测试的是1000并发,所以该图显示的1000并不是mysql数据库的最大并发量。

 

当然“Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)”这个错误信息还有可能由于mysql用户名/密码错误或者权限不够导致无法建立连接。

权限可以在mysql.user表里面查到,Host为localhost的在其他电脑无法访问!!!

jmeter压测mysql Cannot create PoolableConnectionFactory (Could not create connection to database serv

相关文章: