记一次mysql维护经历

因为公司调试用的虚拟机在笔记本上部署的,很久没用了,今天开发老哥做了平台的更新上虚拟机测试发现数据库无法连接,于是喊我搞一下虚拟机。

[root@localhost ~]# ps -aux|grep mysql

然后发现啥都没有

[root@localhost ~]# systemctl start  mysqld.service    
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

启动就报错了
用status查看一下

[root@localhost mysqld]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sat 2019-08-24 17:42:53 CST; 5s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 6030 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 6013 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

Aug 24 17:42:52 localhost.localdomain systemd[1]: Failed to start MySQL Server.
Aug 24 17:42:52 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
Aug 24 17:42:52 localhost.localdomain systemd[1]: mysqld.service failed.
Aug 24 17:42:53 localhost.localdomain systemd[1]: mysqld.service holdoff time over, scheduling restart.
Aug 24 17:42:53 localhost.localdomain systemd[1]: Stopped MySQL Server.
Aug 24 17:42:53 localhost.localdomain systemd[1]: start request repeated too quickly for mysqld.service
Aug 24 17:42:53 localhost.localdomain systemd[1]: Failed to start MySQL Server.
Aug 24 17:42:53 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
Aug 24 17:42:53 localhost.localdomain systemd[1]: mysqld.service failed.

感觉没什么卵用啊。。。
还是看一下日志吧

[root@localhost mysqld]# tail -n 100 /var/log/mysqld.log  
2019-08-24T09:43:36.263600Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-08-24T09:43:36.265223Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.26) starting as process 6219 ...
2019-08-24T09:43:36.268473Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-08-24T09:43:36.268508Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-08-24T09:43:36.268516Z 0 [Note] InnoDB: Uses event mutexes
2019-08-24T09:43:36.268521Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-08-24T09:43:36.268525Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-08-24T09:43:36.268530Z 0 [Note] InnoDB: Using Linux native AIO
2019-08-24T09:43:36.268804Z 0 [Note] InnoDB: Number of pools: 1
2019-08-24T09:43:36.268905Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-08-24T09:43:36.270465Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-08-24T09:43:36.277572Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-08-24T09:43:36.279760Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-08-24T09:43:36.291859Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-08-24T09:43:36.292545Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 1176954594
2019-08-24T09:43:36.292575Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 1176955134
2019-08-24T09:43:36.292877Z 0 [ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 1176954594 and the end 1176955134.
2019-08-24T09:43:36.292893Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2019-08-24T09:43:36.895977Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2019-08-24T09:43:36.896044Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-08-24T09:43:36.896059Z 0 [ERROR] Failed to initialize builtin plugins.
2019-08-24T09:43:36.896067Z 0 [ERROR] Aborting

找到关键

2019-08-24T09:43:36.292877Z 0 [ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 1176954594 and the end 1176955134.

感觉像是在说日志缺失
百度之后发现是ib_logfile0和ib_logfile1两个文件的锅

[root@localhost ~]# cd /var/lib/mysql
[root@localhost mysql]# ll
total 188528
drwxr-x---. 2 mysql mysql     8192 Aug 15 14:38 111
-rw-r-----. 1 mysql mysql       56 Jul 11 13:30 auto.cnf
-rw-------. 1 mysql mysql     1679 Jul 11 13:30 ca-key.pem
-rw-r--r--. 1 mysql mysql     1107 Jul 11 13:30 ca.pem
-rw-r--r--. 1 mysql mysql     1107 Jul 11 13:30 client-cert.pem
-rw-------. 1 mysql mysql     1675 Jul 11 13:30 client-key.pem
-rw-r-----. 1 mysql mysql     2194 Jul 26 17:36 ib_buffer_pool
-rw-r-----. 1 mysql mysql 79691776 Aug 22 15:51 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Aug 22 15:51 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Aug 22 15:51 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 Aug 22 13:44 ibtmp1
drwxr-x---. 2 mysql mysql     4096 Jul 11 13:30 mysql
srwxrwxrwx. 1 mysql mysql        0 Jul 26 17:42 mysql.sock
-rw-------. 1 mysql mysql        5 Jul 26 17:42 mysql.sock.lock
drwxr-x---. 2 mysql mysql     8192 Jul 11 13:30 performance_schema
-rw-------. 1 mysql mysql     1675 Jul 11 13:30 private_key.pem
-rw-r--r--. 1 mysql mysql      451 Jul 11 13:30 public_key.pem
-rw-r--r--. 1 mysql mysql     1107 Jul 11 13:30 server-cert.pem
-rw-------. 1 mysql mysql     1675 Jul 11 13:30 server-key.pem
drwxr-x---. 2 mysql mysql     8192 Jul 11 13:30 sys
drwxr-x---. 2 mysql mysql     8192 Aug 12 19:21 test123
[root@localhost mysql]# rm -rf ib_logfile0
[root@localhost mysql]# rm -rf ib_logfile1
[root@localhost mysql]# systemctl start  mysqld.service
[root@localhost mysql]# systemctl status  mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-08-24 18:10:19 CST; 4s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 7774 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 7757 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 7777 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─7777 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Aug 24 18:10:18 localhost.localdomain systemd[1]: Starting MySQL Server...
Aug 24 18:10:19 localhost.localdomain systemd[1]: Started MySQL Server.

启动成功

后续:重新启动又报错,再次删除这个文件又可以了启动了。。。。emmmmmmmmm反正正式平台没出问题,测试服务器就这么扔着吧

发布了9 篇原创文章 · 获赞 3 · 访问量 597

猜你喜欢

转载自blog.csdn.net/qq_36464516/article/details/100055561