最近服务器(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';
然后尝试将该值改小点,编辑my.cnf,将innodb_buffer_pool_size的值改小点,如果没有,则增加一行
重启Mysql后,再次查看innodb_buffer_pool_size的值看看是否生效
设置生效