-->
当前位置:首页 > DayDayUp > 正文内容

Linux硬重启后磁盘损坏导致MySQL无法启动问题修复

Luz3年前 (2022-11-08)DayDayUp5230

故障现象

服务重启后宝塔面板没法把mysql拉起来了,尝试命令行启动mysql报错

  1. [root@instance-20221108-1616 ~]# service mysqld start
  2. Starting MySQL. ERROR! The server quit without updating PID file (/www/server/data/instance-20221108-1616.pid).

image.png

故障处理

查看MySQL报错日志,报错找不到mysql-bin.index文件

  1. 2022-11-08T12:04:40.000499Z 0 [Warning] option 'max_allowed_packet': unsigned value 107374182400 adjusted to 1073741824
  2. 2022-11-08T12:04:40.000595Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  3. 2022-11-08T12:04:40.000612Z 0 [Note] /www/server/mysql/bin/mysqld (mysqld 5.7.34-log) starting as process 68663 ...
  4. mysqld: File './mysql-bin.index' not found (Errcode: 5 - Input/output error)
  5. 2022-11-08T12:04:40.014762Z 0 [ERROR] Aborting

尝试创建文件也失败了

  1. [root@instance-20221108-1616 data]# touch mysql-bin.index
  2. touch: cannot touch 'mysql-bin.index': Input/output error

尝试给文件夹赋权,失败

  1. [root@instance-20221108-1616 data]# chmod 777 -/www
  2. chmod: cannot access '/www/server/data/ibtmp1': Input/output error
  3. chmod: cannot access '/www/server/data/mysql-bin.index': Input/output error

猜测磁盘损坏

卸载磁盘

  1. [root@instance-20221108-1616 data]# umount /dev/sdb
  2. umount: /www: target is busy.
  3. [root@instance-20221108-1616 data]# umount /www
  4. umount: /www: target is busy.
  5. [root@instance-20221108-1616 data]# umount /dev/sdb -l

尝试恢复报错 cannot open /dev/sdb: Device or resource busy

reboot后重新执行(extX 的分区格式使用fsck修复,XFS分区格式使用 mkfs命令修复 mkfs.xfs -f /dev/sdb1

  1. [root@instance-20221108-1616 ~]# fsck -t ext2 -/dev/sdb
  2. fsck from util-linux 2.32.1
  3. e2fsck 1.45.6 (20-Mar-2020)
  4. /dev/sdb contains a file system with errors, check forced.
  5. Pass 1: Checking inodes, blocks, and sizes
  6. Deleted inode 4727069 has zero dtime.  Fix? yes
  7.  
  8. Deleted inode 4727073 has zero dtime.  Fix? yes
  9.  
  10. Deleted inode 4727074 has zero dtime.  Fix? yes
  11.  
  12. Deleted inode 7184391 has zero dtime.  Fix? yes
  13.  
  14. Deleted inode 7184392 has zero dtime.  Fix? yes
  15.  
  16. Deleted inode 7184393 has zero dtime.  Fix? yes
  17.  
  18. Deleted inode 7184394 has zero dtime.  Fix? yes
  19.  
  20. Deleted inode 7184401 has zero dtime.  Fix? yes
  21.  
  22. Deleted inode 7184402 has zero dtime.  Fix? yes
  23.  
  24. Deleted inode 7184403 has zero dtime.  Fix? yes
  25.  
  26. Deleted inode 7184404 has zero dtime.  Fix? yes
  27.  
  28. Deleted inode 7184405 has zero dtime.  Fix? yes
  29.  
  30. Deleted inode 7184406 has zero dtime.  Fix? yes
  31.  
  32. Extended attribute block 18940418 has reference count 1025, should be 1024.  Fix? yes
  33.  
  34. Extended attribute block 20152834 has reference count 1018, should be 1014.  Fix? yes
  35.  
  36. Extended attribute block 20254344 has reference count 882, should be 876.  Fix? yes
  37.  
  38. Pass 2: Checking directory structure
  39. Entry 'ibtmp1' in /server/data (4046849) has deleted/unused inode 4046850.  Clear? yes
  40.  
  41. Entry 'mysql-bin.index' in /server/data (4046849) has deleted/unused inode 4046878.  Clear? yes
  42.  
  43. Pass 3: Checking directory connectivity
  44. Pass 3A: Optimizing directories
  45. Pass 4: Checking reference counts
  46. Unattached inode 4046879
  47. Connect to /lost+found? yes
  48.  
  49. Inode 4046879 ref count is 2, should be 1.  Fix? yes
  50.  
  51. Unattached inode 4046880
  52. Connect to /lost+found? yes
  53.  
  54. Inode 4046880 ref count is 2, should be 1.  Fix? yes
  55.  
  56. Pass 5: Checking group summary information
  57. Block bitmap differences:  -(16811631--16811636) -(16811638--16812650) -(16812688--16812690) -(16812744--16812754) -(16812880--16813881) -(16813883--16814923) +16814925 -(16814950--16816127) -(18900624--18900630) -(18900728--18900734) -(18900965--18901086) -(18901088--18901094) -(18901159--18907135) -18907650 -(18907656--18913279) -18916738 -18916749 -(18916757--18916795) -(18916818--18916887) -(18916889--18917068) -(18917075--18917144) -(18917146--18917178) -(18917180--18917325) -(18917327--18917431) -(18917433--18919956) -(18919958--18919965) -18920002 -(18920032--18920033) -(18920078--18920379) +18921709 -18939400 -(28835492--28835839) -(28836354--28838548) -(28854739--28854746) -(28949148--28949152) -28976918 -28976920 -28976956 -(29000195--29000391) -(29000395--29000398) -(29000403--29000466) -(29002907--29003035) -(29003043--29003127) -(29003640--29003775) -(29003795--29004007) -(29004012--29004227) -(29004280--29004323)
  58. Fix? yes
  59.  
  60. Free blocks count wrong for group #513 (1132, counted=5385).
  61. Fix? yes
  62.  
  63. Free blocks count wrong for group #576 (0, counted=6120).
  64. Fix? yes
  65.  
  66. Free blocks count wrong for group #577 (3258, counted=12365).
  67. Fix? yes
  68.  
  69. Free blocks count wrong for group #879 (24717, counted=25065).
  70. Fix? yes
  71.  
  72. Free blocks count wrong for group #880 (25304, counted=27507).
  73. Fix? yes
  74.  
  75. Free blocks count wrong for group #883 (29383, counted=29388).
  76. Fix? yes
  77.  
  78. Free blocks count wrong for group #884 (28891, counted=28894).
  79. Fix? yes
  80.  
  81. Free blocks count wrong for group #885 (6450, counted=7538).
  82. Fix? yes
  83.  
  84. Free blocks count wrong (34182084, counted=34205211).
  85. Fix? yes
  86.  
  87. Inode bitmap differences:  -4046850 -4046878 +(4046879--4046880) -4727069 -(4727073--4727074) -(7184391--7184394) -(7184401--7184406)
  88. Fix? yes
  89.  
  90. Free inodes count wrong for group #577 (7853, counted=7856).
  91. Fix? yes
  92.  
  93. Directories count wrong for group #577 (7, counted=6).
  94. Fix? yes
  95.  
  96. Free inodes count wrong for group #877 (8160, counted=8170).
  97. Fix? yes
  98.  
  99. Free inodes count wrong (9705033, counted=9705046).
  100. Fix? yes
  101.  
  102.  
  103. /dev/sdb: ***** FILE SYSTEM WAS MODIFIED *****
  104. /dev/sdb: 125354/9830400 files (0.9% non-contiguous), 5116389/39321600 blocks

修复完成,mysqld启动成功

  1. [root@instance-20221108-1616 ~]# service mysqld start
  2. Starting MySQL. SUCCESS! 
  3. [root@instance-20221108-1616 ~]# pidof mysqld
  4. 18335

image.png

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。