mysql调优之max_allowed_packet
线上启动服务,发现过一会就自动失败退出,然后查看了一下日志
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysJobServiceImpl': Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't store job: Packet for query is too large (2,128 > 1,024). You can change this value on the server by setting the 'max_allowed_packet' variable. [See nested exception: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (2,128 > 1,024). You can change this value on the server by setting the 'max_allowed_packet' variable.]
百度了一下,意思是:指mysql服务器端和客户端在一次传送数据包的过程当中最大允许的数据包大小。
那么问题找到了,怎么解决
临时方法,重启会失效
mysql> show VARIABLES like '%max_allowed_packet%'; +---------------------------+------------+ | Variable_name | Value | +---------------------------+------------+ | max_allowed_packet | 1024 | | mysqlx_max_allowed_packet | 67108864 | | slave_max_allowed_packet | 1073741824 | +---------------------------+------------+ 3 rows in set (0.01 sec) mysql> set global max_allowed_packet = 2*1024*1024*10; Query OK, 0 rows affected (0.00 sec)
退出,重新进入查看即可。
永久,修改配置文件
修改etc/my.cnf ,在mysqld段下添加
max_allowed_packet = 64M
本文来自博客园,作者:不会跳舞的胖子,转载请注明原文链接:https://www.cnblogs.com/rtnb/p/16468725.html