mdadm - Linux Software Raid
主要套件:mdadm
主要服務:mdmonitor (監控 Raid 狀態)
Raid 0
# mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdb /dev/sdc
Raid 1
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc --spare-devices=/dev/sdd
Raid 5
# mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd --spare-devices=/dev/sde
# mkfs.ext4 /dev/md0 # mkdir /data01 # mount /dev/md0 /data01
Raid 設定檔 /etc/mdadm.conf
重新掃描 raid 與更新設定檔 mdadm --verbose --detail -scan > /etc/mdadm.conf
顯示 Raid 整體狀態
cat /proc/mdstat
顯示 /dev/md0 詳細資訊
# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Mon Nov 3 06:03:03 2014
Raid Level : linear
Array Size : 4194288 (4.00 GiB 4.29 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Mon Nov 3 06:03:03 2014
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Rounding : 0K
Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : a50ac9f2:62646d92:725255bd:7f9d30e3
Events : 0
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
/proc/mdstat
# awk '/^md/ {printf "%s: ", $1}; /blocks/ {print $NF}' </proc/mdstat
md126: [UU]
md127: [UUUUU]
# watch -t 'cat /proc/mdstat'
iotop 檢視狀態
# iotop -a -p $(sed 's, , -p ,g' <<<`pgrep "_raid|_resync|jbd2"`)
iostat 檢視狀態
# iostat -dmy 1 /dev/md127 # iostat -dmy 1 /dev/md126
停止並永久移除
# mdadm --stop /dev/md0 # mdadm --remove /dev/md0
啟動 raid
# mdadm --asemble /dev/md0
NOTE : The assemble command reads the /etc/mdadm.conf file to start the array. In case you did not save your configuration in mdadm.conf before stopping the array, this command would fail. You can use the below command to recreate the mdadm.conf file :
# mdadm –examine –scan > /etc/mdadm.conf