Megacli恢復RAID0磁盤數據


  今天干了一件蠢事,距離刪庫跑路,只差一步。把一塊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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM