Mysql莫名奇妙重启
收到客户反馈有时接口报504,查看应用日志发现故障期间数据库连接失败
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
在到数据库服务器查看系统日志/var/log/messages
发现数据库有重启
在查看mysqld.log发现 11:46确实有一些错误日志
搜了网上一些文章,这篇跟我的日志比较吻合
MySQL数据库会莫名其妙地重新启动(adaptive hash index) - 墨天轮
自适应hash索引是什么鬼?
确实是打开的
通过命令设置关闭:set global innodb_adaptive_hash_index=0;
但最好还是在配置文件添加避免服务器重启不生效,最终调整了几个参数如下,看看后面还会不会重启。
[mysqld]
slow_query_log=1 # 开启慢sql查询
long_query_time=2 #查询时间大于2秒的为慢sql
innodb_buffer_pool_size=4G #缓存大小默认是16M,建议设置为总内存的70%
innodb_adaptive_hash_index=OFF