22.3. 使​​​​​​​用​​​​​​​ mdadm 来​​​​​​​配​​​​​​​置​​​​​​​基​​​​​​​于​​​​​​​ RAID 的​​​​​​​多​​​​​​​路​​​​​​​径​​​​​​​贮​​​​​​​存​​​​​​​

和​​​​​​​其​​​​​​​他​​​​​​​在​​​​​​​ raidtools 程​​​​​​​序​​​​​​​包​​​​​​​中​​​​​​​的​​​​​​​工​​​​​​​具​​​​​​​一​​​​​​​样​​​​​​​,可​​​​​​​以​​​​​​​使​​​​​​​用​​​​​​​ mdadm 命​​​​​​​令​​​​​​​来​​​​​​​执​​​​​​​行​​​​​​​所​​​​​​​有​​​​​​​与​​​​​​​管​​​​​​​理​​​​​​​多​​​​​​​设​​​​​​​备​​​​​​​相​​​​​​​关​​​​​​​的​​​​​​​功​​​​​​​能​​​​​​​。​​​​​​​这​​​​​​​一​​​​​​​章​​​​​​​会​​​​​​​解​​​​​​​释​​​​​​​如​​​​​​​何​​​​​​​使​​​​​​​用​​​​​​​ mdadm
  • 创​​​​​​​建​​​​​​​ RAID 设​​​​​​​备​​​​​​​
  • 创​​​​​​​建​​​​​​​多​​​​​​​路​​​​​​​径​​​​​​​设​​​​​​​备​​​​​​​

22.3.1. 使​​​​​​​用​​​​​​​ mdadm 来​​​​​​​创​​​​​​​建​​​​​​​ RAID 设​​​​​​​备​​​​​​​

创​​​​​​​建​​​​​​​ RAID 设​​​​​​​备​​​​​​​:编​​​​​​​辑​​​​​​​ /etc/mdadm.conf,设​​​​​​​置​​​​​​​适​​​​​​​当​​​​​​​的​​​​​​​ DEVICE 和​​​​​​​ ARRAY 的​​​​​​​值​​​​​​​:
DEVICE /dev/sd[abcd]1
ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1,/dev/sdc1,/dev/sdd1
在​​​​​​​这​​​​​​​个​​​​​​​例​​​​​​​子​​​​​​​中​​​​​​​,DEVICE 行​​​​​​​使​​​​​​​用​​​​​​​传​​​​​​​统​​​​​​​的​​​​​​​全​​​​​​​局​​​​​​​文​​​​​​​件​​​​​​​名​​​​​​​(详​​​​​​​细​​​​​​​信​​​​​​​息​​​​​​​参​​​​​​​看​​​​​​​ glob (7)文​​​​​​​档​​​​​​​)来​​​​​​​定​​​​​​​义​​​​​​​以​​​​​​​下​​​​​​​的​​​​​​​ SCSI 设​​​​​​​备​​​​​​​:
  • /dev/sda1
  • /dev/sdb1
  • /dev/sdc1
  • /dev/sdd1
ARRAY 行​​​​​​​定​​​​​​​义​​​​​​​了​​​​​​​一​​​​​​​个​​​​​​​ RAID 设​​​​​​​备​​​​​​​(/dev/md0),它​​​​​​​是​​​​​​​由​​​​​​​被​​​​​​​ DEVICE 行​​​​​​​定​​​​​​​义​​​​​​​的​​​​​​​ SCSI 设​​​​​​​备​​​​​​​组​​​​​​​成​​​​​​​的​​​​​​​。​​​​​​​
在​​​​​​​建​​​​​​​立​​​​​​​或​​​​​​​使​​​​​​​用​​​​​​​任​​​​​​​何​​​​​​​ RAID 设​​​​​​​备​​​​​​​以​​​​​​​前​​​​​​​,/proc/mdstat 文​​​​​​​件​​​​​​​不​​​​​​​包​​​​​​​括​​​​​​​任​​​​​​​何​​​​​​​激​​​​​​​活​​​​​​​的​​​​​​​ RAID 设​​​​​​​备​​​​​​​。​​​​​​​
Personalities :
read_ahead not set
Event: 0
unused devices: none
接​​​​​​​下​​​​​​​来​​​​​​​,使​​​​​​​用​​​​​​​以​​​​​​​上​​​​​​​的​​​​​​​设​​​​​​​置​​​​​​​和​​​​​​​ mdadm 命​​​​​​​令​​​​​​​来​​​​​​​建​​​​​​​立​​​​​​​一​​​​​​​个​​​​​​​ RAID 0 阵​​​​​​​列​​​​​​​。​​​​​​​
mdadm -C /dev/md0 --level=raid0 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 \
/dev/sdd1
Continue creating array? yes
mdadm: array /dev/md0 started.
一​​​​​​​旦​​​​​​​它​​​​​​​被​​​​​​​建​​​​​​​立​​​​​​​,RAID 设​​​​​​​备​​​​​​​的​​​​​​​状​​​​​​​态​​​​​​​信​​​​​​​息​​​​​​​可​​​​​​​以​​​​​​​在​​​​​​​任​​​​​​​何​​​​​​​时​​​​​​​候​​​​​​​被​​​​​​​查​​​​​​​询​​​​​​​到​​​​​​​。​​​​​​​以​​​​​​​下​​​​​​​的​​​​​​​例​​​​​​​子​​​​​​​显​​​​​​​示​​​​​​​了​​​​​​​ mdadm --detail /dev/md0 命​​​​​​​令​​​​​​​的​​​​​​​输​​​​​​​出​​​​​​​结​​​​​​​果​​​​​​​:
/dev/md0:
Version : 00.90.00
Creation Time : Mon Mar  1 13:49:10 2004
Raid Level : raid0
Array Size : 15621632 (14.90 GiB 15.100 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Mon Mar  1 13:49:10 2004
State : dirty, no-errors
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Chunk Size : 64K

      Number   Major   Minor   RaidDevice State
         0       8        1        0      active sync   /dev/sda1
         1       8       17        1      active sync   /dev/sdb1
         2       8       33        2      active sync   /dev/sdc1
         3       8       49        3      active sync   /dev/sdd1
           UUID : 25c0f2a1:e882dfc0:c0fe135e:6940d932
         Events : 0.1

为了尽快向用户提供最新的信息,本文档可能会包括由机器自动从英文原文翻译的内容。如需更多信息,请参阅此说明。