前段时间清理二进制文件,在今天小编重启MySQL服务导致无法启动,并且没有日志
root@yungnet:~# /etc/init.d/mysqld start
Starting mysqld (via systemctl): mysqld.serviceJob for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
failed!
root@yungnet:~# lsof -i :3306
root@yungnet:~#
mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/init.d/mysqld; generated)
Active: failed (Result: exit-code) since Mon 2025-10-27 11:57:39 CST; 38s ago
Docs: man:systemd-sysv-generator(8)
Process: 34909 ExecStart=/etc/init.d/mysqld start (code=exited, status=1/FAILURE)
CPU: 1.224s
Oct 27 11:57:36 yungnet.cn systemd[1]: Starting LSB: start and stop MySQL...
Oct 27 11:57:39 yungnet.cn mysqld[34909]: Starting MySQL...The server quit without updating PID file (/www/serv>
Oct 27 11:57:39 yungnet.cn mysqld[35632]: failed!
Oct 27 11:57:39 yungnet.cn systemd[1]: mysqld.service: Control process exited, code=exited, status=1/FAILURE
Oct 27 11:57:39 yungnet.cn systemd[1]: mysqld.service: Failed with result 'exit-code'.
Oct 27 11:57:39 yungnet.cn systemd[1]: Failed to start LSB: start and stop MySQL.
Oct 27 11:57:39 yungnet.cn systemd[1]: mysqld.service: Consumed 1.224s CPU time.
看到这个情况很多人会选择重装MySQL算了,找也找不到故障点,但是作为一个运维,可以告诉大家,很简单的,我们一步一步排查
首先尝试手动启动,日志提示
/www/server/mysql/bin/mysqld, Version: 5.7.44-log (Source distribution). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
那换一种方式,使用journalctl -u mysqld | tail -30尝试查找故障点
Oct 27 12:10:45 yungnet.cn systemd[1]: mysqld.service: Consumed 1.119s CPU time.
Oct 27 12:10:45 yungnet.cn systemd[1]: Starting LSB: start and stop MySQL...
Oct 27 12:10:49 yungnet.cn mysqld[12214]: Starting MySQL...The server quit without updating PID file (/www/server/data/yungnet.cn.pid). ...
Oct 27 12:10:49 yungnet.cn mysqld[12942]: failed!
Oct 27 12:10:49 yungnet.cn systemd[1]: mysqld.service: Control process exited, code=exited, status=1/FAILURE
Oct 27 12:10:49 yungnet.cn systemd[1]: mysqld.service: Failed with result 'exit-code'.
Oct 27 12:10:49 yungnet.cn systemd[1]: Failed to start LSB: start and stop MySQL.
Oct 27 12:10:49 yungnet.cn systemd[1]: mysqld.service: Consumed 1.107s CPU time.
Oct 27 12:10:49 yungnet.cn systemd[1]: Starting LSB: start and stop MySQL...
Oct 27 12:10:52 yungnet.cn mysqld[12945]: Starting MySQL...The server quit without updating PID file (/www/server/data/yungnet.cn.pid). ...
Oct 27 12:10:52 yungnet.cn mysqld[13666]: failed!
Oct 27 12:10:52 yungnet.cn systemd[1]: mysqld.service: Control process exited, code=exited, status=1/FAILURE
Oct 27 12:10:52 yungnet.cn systemd[1]: mysqld.service: Failed with result 'exit-code'.
Oct 27 12:10:52 yungnet.cn systemd[1]: Failed to start LSB: start and stop MySQL.
Oct 27 12:10:52 yungnet.cn systemd[1]: mysqld.service: Consumed 1.135s CPU time.
Oct 27 12:10:53 yungnet.cn systemd[1]: Starting LSB: start and stop MySQL...
Oct 27 12:10:56 yungnet.cn mysqld[13681]: Starting MySQL...The server quit without updating PID file (/www/server/data/yungnet.cn.pid). ...
Oct 27 12:10:56 yungnet.cn mysqld[14420]: failed!
Oct 27 12:10:56 yungnet.cn systemd[1]: mysqld.service: Control process exited, code=exited, status=1/FAILURE
Oct 27 12:10:56 yungnet.cn systemd[1]: mysqld.service: Failed with result 'exit-code'.
Oct 27 12:10:56 yungnet.cn systemd[1]: Failed to start LSB: start and stop MySQL.
Oct 27 12:10:56 yungnet.cn systemd[1]: mysqld.service: Consumed 1.126s CPU time.
Oct 27 12:10:56 yungnet.cn systemd[1]: Starting LSB: start and stop MySQL...
Oct 27 12:10:59 yungnet.cn mysqld[14423]: Starting MySQL...The server quit without updating PID file (/www/server/data/yungnet.cn.pid). ...
Oct 27 12:10:59 yungnet.cn mysqld[15163]: failed!
Oct 27 12:10:59 yungnet.cn systemd[1]: mysqld.service: Control process exited, code=exited, status=1/FAILURE
Oct 27 12:10:59 yungnet.cn systemd[1]: mysqld.service: Failed with result 'exit-code'.
Oct 27 12:10:59 yungnet.cn systemd[1]: Failed to start LSB: start and stop MySQL.
Oct 27 12:10:59 yungnet.cn systemd[1]: mysqld.service: Consumed 1.067s CPU time.
Oct 27 12:11:00 yungnet.cn systemd[1]: Starting LSB: start and stop MySQL...
不错,故障原因逐渐清晰,发现pid无法更新
Oct 27 12:10:56 yungnet.cn mysqld[13681]: Starting MySQL...The server quit without updating PID file (/www/server/data/yungnet.cn.pid). ...
Oct 27 12:10:56 yungnet.cn mysqld[14420]: failed!
为什么无法更新呢,还需要继续排查,我们先不依靠/etc/init.d/mysqld start命令,使用/www/server/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --console手动启动看看
2025-10-27T04:15:31.335598Z 0 [Warning] option 'max_allowed_packet': unsigned value 107374182400 adjusted to 1073741824
2025-10-27T04:15:31.335786Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2025-10-27T04:15:31.335792Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2025-10-27T04:15:31.335830Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2025-10-27T04:15:31.335868Z 0 [Note] /www/server/mysql/bin/mysqld (mysqld 5.7.44-log) starting as process 18945 ...
2025-10-27T04:15:31.346443Z 0 [Note] InnoDB: PUNCH HOLE support available
2025-10-27T04:15:31.346485Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2025-10-27T04:15:31.346491Z 0 [Note] InnoDB: Uses event mutexes
2025-10-27T04:15:31.346497Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2025-10-27T04:15:31.346503Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2025-10-27T04:15:31.346910Z 0 [Note] InnoDB: Number of pools: 1
2025-10-27T04:15:31.347120Z 0 [Note] InnoDB: Using CPU crc32 instructions
2025-10-27T04:15:31.349080Z 0 [Note] InnoDB: Initializing buffer pool, total size = 64M, instances = 1, chunk size = 64M
2025-10-27T04:15:31.356939Z 0 [Note] InnoDB: Completed initialization of buffer pool
2025-10-27T04:15:31.360738Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2025-10-27T04:15:31.374577Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2025-10-27T04:15:31.392063Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2025-10-27T04:15:31.392171Z 0 [Note] InnoDB: Setting file '/www/server/data/ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2025-10-27T04:15:31.410556Z 0 [Note] InnoDB: File '/www/server/data/ibtmp1' size is now 12 MB.
2025-10-27T04:15:31.411387Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2025-10-27T04:15:31.411418Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2025-10-27T04:15:31.412802Z 0 [Note] InnoDB: Waiting for purge to start
2025-10-27T04:15:31.463324Z 0 [Note] InnoDB: 5.7.44 started; log sequence number 6255661077
2025-10-27T04:15:31.463650Z 0 [Note] InnoDB: Loading buffer pool(s) from /www/server/data/ib_buffer_pool
2025-10-27T04:15:31.463886Z 0 [Note] Plugin 'FEDERATED' is disabled.
2025-10-27T04:15:31.465139Z 0 [Note] InnoDB: Buffer pool(s) load completed at 251027 12:15:31
mysqld: File './mysql-bin.000033' not found (Errcode: 2 - No such file or directory)
2025-10-27T04:15:31.467979Z 0 [ERROR] Failed to open log (file './mysql-bin.000033', errno 2)
2025-10-27T04:15:31.467986Z 0 [ERROR] Could not open log file
2025-10-27T04:15:31.467991Z 0 [ERROR] Can't init tc log
2025-10-27T04:15:31.467995Z 0 [ERROR] Aborting
2025-10-27T04:15:31.468008Z 0 [Note] Binlog end
2025-10-27T04:15:31.468101Z 0 [Note] Shutting down plugin 'ngram'
2025-10-27T04:15:31.468119Z 0 [Note] Shutting down plugin 'partition'
2025-10-27T04:15:31.468125Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2025-10-27T04:15:31.468136Z 0 [Note] Shutting down plugin 'ARCHIVE'
2025-10-27T04:15:31.468140Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2025-10-27T04:15:31.468255Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2025-10-27T04:15:31.468266Z 0 [Note] Shutting down plugin 'MyISAM'
2025-10-27T04:15:31.468289Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2025-10-27T04:15:31.468297Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2025-10-27T04:15:31.468301Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2025-10-27T04:15:31.468305Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2025-10-27T04:15:31.468313Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2025-10-27T04:15:31.468317Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2025-10-27T04:15:31.468332Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2025-10-27T04:15:31.468336Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2025-10-27T04:15:31.468339Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2025-10-27T04:15:31.468350Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2025-10-27T04:15:31.468354Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2025-10-27T04:15:31.468361Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2025-10-27T04:15:31.468368Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2025-10-27T04:15:31.468375Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2025-10-27T04:15:31.468382Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2025-10-27T04:15:31.468389Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2025-10-27T04:15:31.468396Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2025-10-27T04:15:31.468403Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2025-10-27T04:15:31.468419Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2025-10-27T04:15:31.468423Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2025-10-27T04:15:31.468427Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2025-10-27T04:15:31.468430Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2025-10-27T04:15:31.468434Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2025-10-27T04:15:31.468441Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2025-10-27T04:15:31.468445Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2025-10-27T04:15:31.468479Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2025-10-27T04:15:31.468483Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2025-10-27T04:15:31.468487Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2025-10-27T04:15:31.468493Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2025-10-27T04:15:31.468500Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2025-10-27T04:15:31.468504Z 0 [Note] Shutting down plugin 'InnoDB'
2025-10-27T04:15:31.468633Z 0 [Note] InnoDB: FTS optimize thread exiting.
2025-10-27T04:15:31.468726Z 0 [Note] InnoDB: Starting shutdown...
2025-10-27T04:15:31.569093Z 0 [Note] InnoDB: Dumping buffer pool(s) to /www/server/data/ib_buffer_pool
2025-10-27T04:15:31.569378Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 251027 12:15:31
2025-10-27T04:15:32.875722Z 0 [Note] InnoDB: Shutdown completed; log sequence number 6255661096
2025-10-27T04:15:32.877937Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2025-10-27T04:15:32.877972Z 0 [Note] Shutting down plugin 'MEMORY'
2025-10-27T04:15:32.877984Z 0 [Note] Shutting down plugin 'CSV'
2025-10-27T04:15:32.877995Z 0 [Note] Shutting down plugin 'sha256_password'
2025-10-27T04:15:32.878003Z 0 [Note] Shutting down plugin 'mysql_native_password'
2025-10-27T04:15:32.878178Z 0 [Note] Shutting down plugin 'binlog'
2025-10-27T04:15:32.878980Z 0 [Note] /www/server/mysql/bin/mysqld: Shutdown complete
ok,故障点已经找到了,从错误日志中可以看到,MySQL启动失败的原因是:
mysqld: File './mysql-bin.000033' not found (Errcode: 2 - No such file or directory)
2025-10-27T04:15:31.467979Z 0 [ERROR] Failed to open log (file './mysql-bin.000033', errno 2)
这意味着MySQL在启动时试图打开二进制日志文件'./mysql-bin.000033',但是该文件不存在。
在MySQL配置中,我们开启了二进制日志(log-bin=mysql-bin),所以MySQL会尝试按照二进制日志的索引文件(通常是mysql-bin.index)中记录的文件名来打开二进制日志文件。
回到宝塔,我们临时关闭二进制日志记录再次启动

欧克,成功启动,但是关闭二进制也解决不了问题,更何况会存在很多数据丢失风险,我们通过先备份后重置二进制方式,来解决该问题,至此解决了
# 停止MySQL(如果正在运行)
/etc/init.d/mysqld stop
# 备份当前数据
cp -r /www/server/data /www/server/data_backup_$(date +%Y%m%d_%H%M%S)
# 检查现有的二进制日志文件
ls -la /www/server/data/mysql-bin.*
# 重置二进制日志
cd /www/server/data
rm -f mysql-bin.*
rm mysql-bin.index

ok,解决,下课!
广告:
© 版权声明
THE END








暂无评论内容