用mdadm重建RAID硬碟陣列

因為怕自己忘記,也給需要的人參考,把一些Linux的處理過程記下來。先前建好的RAID硬碟陣列,若是其中一顆有問題,把它取出後,用mdadm命令看RAID,應該看到類似下面的資料,其中一個不見了(dev/sdd,以RAID5為例)

# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Sep 11 23:03:51 2016
Raid Level : raid5
Array Size : 4395021312 (4191.42 GiB 4500.50 GB)
Used Dev Size : 1465007104 (1397.14 GiB 1500.17 GB)
Raid Devices : 4
Total Devices : 3
Persistence : Superblock is persistent
 
Intent Bitmap : Internal
 
Update Time : Thu Sep 15 22:03:33 2016
State : clean, degraded
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
 
Layout : left-symmetric
Chunk Size : 512K
 
Name : NM70-1037u:0 (local to host NM70-1037u)
UUID : a2fc4bf3:bb676d76:1bbacffa:d12a8e45
Events : 84715
 
Number Major Minor RaidDevice State
0 8 0 0 active sync /dev/sda
1 8 16 1 active sync /dev/sdb
2 8 32 2 active sync /dev/sdc
6 0 0 6 removed

加入可用的硬碟後,先用 fdisk 看看有沒有分割,若有要先刪掉,
~# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
命令 (m 以獲得說明): p
Disk /dev/sdd: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x00057c4d
 
命令 (m 以獲得說明): q

之後,用mdadm –add加入新硬碟
~# mdadm --add /dev/md0 /dev/sdd
mdadm: added /dev/sdd

再看一次 mdadm -D,重建中…
~# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sun Sep 11 23:03:51 2016
Raid Level : raid5
Array Size : 4395021312 (4191.42 GiB 4500.50 GB)
Used Dev Size : 1465007104 (1397.14 GiB 1500.17 GB)
Raid Devices : 4
Total Devices : 4
Persistence : Superblock is persistent
 
Intent Bitmap : Internal
 
Update Time : Thu Sep 15 22:04:56 2016
State : clean, degraded, recovering
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
 
Layout : left-symmetric
Chunk Size : 512K
 
Rebuild Status : 0% complete
 
Name : NM70-1037u:0 (local to host NM70-1037u)
UUID : a2fc4bf3:bb676d76:1bbacffa:d12a8e45
Events : 84763
 
Number Major Minor RaidDevice State
0 8 0 0 active sync /dev/sda
1 8 16 1 active sync /dev/sdb
2 8 32 2 active sync /dev/sdc
4 8 48 3 spare rebuilding /dev/sdd

看/proc/mdstat,可以看到重建的進度和寫入速度
~# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10]
md0 : active raid5 sdd[4] sdc[2] sdb[1] sda[0]
4395021312 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_]
[>....................] recovery = 1.3% (19328144/1465007104) finish=223.4min speed=107814K/sec
bitmap: 11/11 pages [44KB], 65536KB chunk
 
unused devices:

等到100%就修復完成了。

(Visited 3,653 times, 1 visits today)

在〈用mdadm重建RAID硬碟陣列〉中有 1 則留言

發佈留言