[关闭]
@llplmlyd 2021-02-08T11:37:00.000000Z 字数 2517 阅读 677

mysql.sock 套接字文件丢失案例分析

数据库


mysql.sock 不存在的几种情况

本次异常属于第四种

定位分析开发环境大量数据库缺失 mysql.sock 文件的原因。目前定位是 在相应机器上部署了定时任务

*/1 * * * * /usr/local/mysql33066/start.sh &

导致 当数据库mysqld子进程异常退出,而父进程mysqld_safe仍未退出,但定时脚本同步运行拉起,其中运行了mysqld_safe,mysqld_safe同步再次拉起mysqld,导致mysqld启动错误,此时定时任务的mysqld_safe误将原父进程生成的mysql.scok清除

  1. ## 查看异常数据库对应的启动语句的进程号 以及sock文件是否创建
  2. cat error.lock|grep -i 'start|sock'
  3. # cat error.log |grep -E 'start|sock'
  4. 2020-04-02T17:27:24.406346+08:00 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2954e695-74c4-11ea-a081-fa162647b44e.
  5. 2020-04-02T17:27:28.556365+08:00 0 [Note] /usr/local/mysql33066/bin/mysqld (mysqld 5.7.25-28-log) starting as process 2198 ...
  6. 2020-04-02T17:27:29.279269+08:00 0 [Note] InnoDB: Waiting for purge to start
  7. 2020-04-02T17:27:29.329502+08:00 0 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.7.25-28 started; log sequence number 2529424
  8. 2020-04-02T17:27:29.361113+08:00 0 [Note] Server socket created on IP: '10.176.49.49'.
  9. 2020-04-02T17:27:29.424075+08:00 0 [Note] Failed to start slave threads for channel ''
  10. Version: '5.7.25-28-log' socket: '/usr/local/mysql33066/tmp/mysql.sock' port: 33066 Source distribution
  11. ----------------------------
  12. 2020-08-10T03:00:03.552903+08:00 0 [Note] /usr/local/mysql33066/bin/mysqld (mysqld 5.7.25-28-log) starting as process 389369 ...
  13. 2020-08-20T17:55:06.158180+08:00 0 [Note] /usr/local/mysql33066/bin/mysqld (mysqld 5.7.25-28-log) starting as process 622502 ...
  14. ... ...
  15. 2021-02-04T17:12:03.651118+08:00 0 [Note] /usr/local/mysql33066/bin/mysqld (mysqld 5.7.25-28-log) starting as process 68198 ...
  16. 2021-02-04T17:12:04.706579+08:00 0 [Note] InnoDB: Waiting for purge to start
  17. 2021-02-04T17:12:04.756850+08:00 0 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.7.25-28 started; log sequence number 602434766
  18. 2021-02-04T17:12:08.604898+08:00 0 [Note] Server socket created on IP: '10.176.49.49'.
  19. 2021-02-04T17:12:08.837762+08:00 0 [Note] Failed to start slave threads for channel ''
  20. Version: '5.7.25-28-log' socket: '/usr/local/mysql33066/tmp/mysql.sock' port: 33066 Source distribution
  21. 2021-02-04T18:13:23.261404+08:00 0 [Note] /usr/local/mysql33066/bin/mysqld (mysqld 5.7.25-28-log) starting as process 91869 ...
  22. ## ps -ef 查看当前子进程的进程号,同时可以查看对应进程有些版本是有的mysql.sock.lock文件的创建日期
  23. 查看可发现 当前子进程的进程号仍是2198 可发现在未正常处理退出mysqld_safe之前的进程一直停留在了2198
  24. -rw------- 1 mysql mysql 6 2020 ? mysql.sock.lock
  25. ### 中间的过程均是由于进程冲突 导致的重启失败 error log频繁显示冲突
  26. [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
  27. 2021-02-04T18:13:23.650882+08:00 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注