Linux

MDADM首先准备一台Linux系统虚拟机然后添加两块儿硬盘,大小为30G


                              
echo "- - -"        >/sys/class/scsi_host/host0/scan
echo "- - -"        >/sys/class/scsi_host/host1/scan
echo "- - -"        >/sys/class/swcsi_host/host2/scan
重新扫描磁盘把新加的磁盘更新出来


#fdisk/dev/sdb 将磁盘分区
#fdisk-l查看磁盘格式
sdb1的操作和sdc1操作一样


建立RAID1#mdadm -C/dev/md0 -l 1 -n 2 /dev/sd[bc]1
mdadm: Note: this array has metadata at the startand
    may notbe suitable as a boot device.  If youplan to
    store'/boot' on this device please ensure that
    yourboot-loader understands md/v1.x metadata, or use
   --metadata=0.90
Continue creating array? yes
mdadm: Defaulting to version 1.2 metadata
mdadm:array /dev/md0 started.

创建文件系统格式化该磁盘阵列
#mkfs.ext4/dev/md0
# mkdir/data
# mount/dev/md0 /data
# ll /data/
total 16
drwx------2 root root 16384 Aug 14 15:21 lost+found

# vi/etc/fstab
在最后添加如下内容
/dev/md0        /data                   ext4    defaults        0 0
# mdadm -Ds
ARRAY /dev/md0 metadata=1.2name=localhost.localdomain:0 UUID=c03306c3:6afc2397:ba52fc78:2c3332de


写入到配置文件
# mdadm -Ds>> /etc/mdadm.conf
重新启动验证
# Reboot

# cat/proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[0] sdc1[1]
     31438720 blocks super 1.2 [2/2] [UU]


unused devices: <none>

模拟故障sdb 删除
cat /proc/mdstat查看是否删除
Personalities : [raid1]
md0 : active raid1 sdb1[0](F) sdc1[1]
     31438720 blocks super 1.2 [2/1] [_U]


unused devices: <none>
RAID1重建模拟恢复,还是30G的硬盘,添加新磁盘30G

#fdisk-l /dev/sdb 查看sdb磁盘格式

在线加入新组成单元
# mdadm/dev/md0 -a /dev/sdb1

mdadm: added /dev/sdb1

# cat /proc/mdstatss

Personalities : [raid1]

md0 : active raid1 sdb1[2] sdc1[1]

      31438720 blocks super 1.2 [2/1] [_U]

      [=>...................]  recovery =  7.0% (2201920/31438720) finish=2.4min speed=200174K/sec

 

unused devices: <none>

在日志中看到重建的过程

 

md: bind<sdb1>

md: recovery of RAID array md0

md: minimum _guaranteed_  speed: 1000 KB/sec/disk.

md: using maximum available idle IO bandwidth  (but not more than 200000 KB/sec) for recovery.

md: using 128k window, over a total of 31438720k.

md: md0: recovery done.




你可能感兴趣的:(linux,磁盘)