今天干了一件蠢事,距离删库跑路,只差一步。把一块RAID0的磁盘给拔掉了,拔掉之后发现这是一块数据盘,幸好这个数据库是一台备库。赶紧动手恢复,以下是恢复的过程。
首先把拔下来的盘插回去,通过Megacli查看状态是这样的
root# /opt/MegaRAID/MegaCli/MegaCli64 -pdlist -aall
......
Enclosure Device ID: 32 Slot Number: 7 Enclosure position: 1 Device Id: 7 WWN: 5000c5004de11ef8 Sequence Number: 15 Media Error Count: 0 Other Error Count: 4 Predictive Failure Count: 0 Last Predictive Failure Event Seq Number: 0 PD Type: SATA Raw Size: 1.819 TB [0xe8e088b0 Sectors] Non Coerced Size: 1.818 TB [0xe8d088b0 Sectors] Coerced Size: 1.818 TB [0xe8d00000 Sectors] Sector Size: 0 Firmware state: Unconfigured(good), Spun Up Device Firmware Level: PA07 Shield Counter: 0 Successful diagnostics completion on : N/A SAS Address(0): 0x4433221103000000 Connected Port Number: 5(path0) Inquiry Data: Z1P3CVR1ST2000NM0011 PA07 FDE Capable: Not Capable FDE Enable: Disable Secured: Unsecured Locked: Unlocked Needs EKM Attention: No Foreign State: Foreign Foreign Secure: Drive is not secured by a foreign lock key Device Speed: 3.0Gb/s Link Speed: 3.0Gb/s Media Type: Hard Disk Device Drive Temperature :38C (100.40 F) PI Eligibility: No Drive is formatted for PI information: No PI: No PI Drive's NCQ setting : N/A Port-0 : Port status: Active Port's Linkspeed: 3.0Gb/s Drive has flagged a S.M.A.R.T alert : No
可以看到磁盘的状态变成了Firmware state: Unconfigured(good),Foreign State: Foreign。
查看原RAID0的组ID,这里看到源RAID0组ID为1
root@proxmox35:~# /opt/MegaRAID/MegaCli/MegaCli64 -GetPreservedCacheList -a0 Adapter #0 Virtual Drive(Target ID 01): Missing. Exit Code: 0x00
先清除一下磁盘的Foreign状态
root@proxmox35:~# /opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -clear -a0 Foreign configuration 0 is cleared on controller 0. Exit Code: 0x00
然后直接新建RAID0组
root@proxmox35:~# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[32:7] WB Direct -a0 Adapter 0: Configure Adapter Failed FW error description: The current operation is not allowed because the controller has data in cache for offline or missing virtual drives. Exit Code: 0x54
这里报出有缓存需要清理,我们做下清理操作
root@proxmox35:~# /opt/MegaRAID/MegaCli/MegaCli64 -DiscardPreservedCache -L1 -a0 Adapter #0 Virtual Drive(Target ID 01): Preserved Cache Data Cleared. Exit Code: 0x00
#然后再次尝试添加RAID0组
root@proxmox35:~# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [32:7] -a0
Adapter 0: Created VD 1
Adapter 0: Configured the Adapter!!
通过fdisk查看磁盘,已经能看到恢复回去的磁盘了,而且里面是带有之前的分区信息
root@proxmox35:~# fdisk -l
......
Disk /dev/sdd: 1.8 TiB, 1999844147200 bytes, 3905945600 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xd9109a0a Device Boot Start End Sectors Size Id Type /dev/sdd1 2048 209717247 209715200 100G 83 Linux #这里的设备需要可能跟之前的不一样需要自己根据情况观察
......
剩下的就是把之前的挂载目录卸载,重新挂载恢复回来的盘符就可以了。
root@proxmox35:/mnt# ls ls: reading directory '.': Input/output error root@proxmox35:/mnt# cd .. root@proxmox35:/# umount /mnt #这里如果出现 Device busy报错,加个 -l 参数即可 root@proxmox35:/# mount /dev/sdd1 /mnt root@proxmox35:/# cd /mnt root@proxmox35:/mnt# ls 8.07.14_MegaCLI.txt 8-07-14_MegaCLI.zip a1 a2 a3 a4 b1 b2 b3 b4 c1 c2 c3 c4 CmdTool.log d1 d2 d3 d4 e1 e2 e3 e4 lost+found MegaSAS.log