MySQL 运行一段时间后自动停止了,也无法启动

Mysql tytrock ⋅ 于 2021-03-05 16:34:04 ⋅ 2075 阅读

最近服务器(Centos7.4)下的mysql经常在运行一段时间后就自动停止了,也无法再次启动,必须重启服务器才能启动


查了一下mysql的错误日志

210303 20:47:35 mysqld_safe Starting mysqld daemon with databases from /data/mysql
2021-03-03 20:47:36 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-03-03 20:47:36 1051 [Note] Plugin 'FEDERATED' is disabled.
2021-03-03 20:47:36 1051 [Note] InnoDB: Using atomics to ref count buffer pool pages
2021-03-03 20:47:36 1051 [Note] InnoDB: The InnoDB memory heap is disabled
2021-03-03 20:47:36 1051 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-03-03 20:47:36 1051 [Note] InnoDB: Memory barrier is not used
2021-03-03 20:47:36 1051 [Note] InnoDB: Compressed tables use zlib 1.2.3
2021-03-03 20:47:36 1051 [Note] InnoDB: Using CPU crc32 instructions
2021-03-03 20:47:36 1051 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2021-03-03 20:47:36 1051 [Note] InnoDB: Completed initialization of buffer pool
2021-03-03 20:47:36 1051 [Note] InnoDB: Highest supported file format is Barracuda.
2021-03-03 20:47:36 1051 [Note] InnoDB: Log scan progressed past the checkpoint lsn 39011207
2021-03-03 20:47:36 1051 [Note] InnoDB: Database was not shutdown normally!
2021-03-03 20:47:36 1051 [Note] InnoDB: Starting crash recovery.
2021-03-03 20:47:36 1051 [Note] InnoDB: Reading tablespace information from the .ibd files...
2021-03-03 20:47:37 1051 [Note] InnoDB: Restoring possible half-written data pages 
2021-03-03 20:47:37 1051 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 39023198
2021-03-03 20:47:37 1051 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed
2021-03-03 20:47:38 1051 [Note] InnoDB: 128 rollback segment(s) are active.
2021-03-03 20:47:38 1051 [Note] InnoDB: Waiting for purge to start
2021-03-03 20:47:38 1051 [Note] InnoDB: 5.6.21 started; log sequence number 39023198
2021-03-03 20:47:38 1051 [Note] Server hostname (bind-address): '*'; port: 3306
2021-03-03 20:47:38 1051 [Note] IPv6 is available.
2021-03-03 20:47:38 1051 [Note]   - '::' resolves to '::';
2021-03-03 20:47:38 1051 [Note] Server socket created on IP: '::'.
2021-03-03 20:47:38 1051 [Note] Event Scheduler: Loaded 0 events
2021-03-03 20:47:38 1051 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.6.21'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
210304 14:14:33 mysqld_safe Number of processes running now: 0
210304 14:14:33 mysqld_safe mysqld restarted
2021-03-04 14:14:33 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).


网上查阅了一番,大概都是说服务器内存不够用,不过这台服务器的内存也的确是低,只有1G内存。


解决方法:

1、提升服务器内存

2、修改innodb_buffer_pool_size值(待验证)

先进入mysql查看当前innodb_buffer_pool_size设置的值是多少

show global variables like 'innodb_buffer_pool_size';

image.png

然后尝试将该值改小点,编辑my.cnf,将innodb_buffer_pool_size的值改小点,如果没有,则增加一行

image.png

重启Mysql后,再次查看innodb_buffer_pool_size的值看看是否生效

image.png

设置生效

回复数量: 0
    暂无评论~~
    • 请注意单词拼写,以及中英文排版,参考此页
    • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`, 更多语法请见这里 Markdown 语法
    • 支持表情,使用方法请见 Emoji 自动补全来咯,可用的 Emoji 请见 :metal: :point_right: Emoji 列表 :star: :sparkles:
    • 上传图片, 支持拖拽和剪切板黏贴上传, 格式限制 - jpg, png, gif
    • 发布框支持本地存储功能,会在内容变更时保存,「提交」按钮点击时清空
    Ctrl+Enter