使用者工具

網站工具


tech:softraid

Linux 軟體磁碟陣列

基本查詢命令語法

cat /proc/mdstat |h
Personalities : [raid1]
read_ahead 1024 sectors
md3 : active raid1 hdc5[0] hdd5[1]
      115113600 blocks [2/2] [UU]
 
md2 : active raid1 hdc3[0] hdd3[1]
      20482752 blocks [2/2] [UU]
 
md1 : active raid1 hdc2[0] hdd2[1]
      20482752 blocks [2/2] [UU]
 
md0 : active raid1 hdc1[0] hdd1[1]
      208704 blocks [2/2] [UU]
 
unused devices: <none>
lsraid |h
lsraid -a /dev/md0
 
[[email protected] etc]# lsraid -a /dev/md0
[dev   9,   0] /dev/md0         57F98AC6.91021808.E5F058A3.91E9FE17 online
[dev  22,   1] /dev/hdc1        57F98AC6.91021808.E5F058A3.91E9FE17 good
[dev  22,  65] /dev/hdd1        57F98AC6.91021808.E5F058A3.91E9FE17 good
 
[[email protected] etc]# lsraid -a /dev/md1
[dev   9,   1] /dev/md1         4A2262E4.6B0C39AA.59C5AEAF.4FC41204 online
[dev  22,   2] /dev/hdc2        4A2262E4.6B0C39AA.59C5AEAF.4FC41204 good
[dev  22,  66] /dev/hdd2        4A2262E4.6B0C39AA.59C5AEAF.4FC41204 good
 
[[email protected] etc]# lsraid -a /dev/md2
[dev   9,   2] /dev/md2         4A103E27.D5B51E66.AA3D7DEA.EF7AB400 online
[dev  22,   3] /dev/hdc3        4A103E27.D5B51E66.AA3D7DEA.EF7AB400 good
[dev  22,  67] /dev/hdd3        4A103E27.D5B51E66.AA3D7DEA.EF7AB400 good
mdadm |h
mdadm --detail /dev/md0
 
/dev/md0:
        Version : 00.90.00
  Creation Time : Tue Aug 31 23:35:15 2004
     Raid Level : raid1
     Array Size : 208704 (203.81 MiB 213.71 MB)
    Device Size : 208704 (203.81 MiB 213.71 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent
 
    Update Time : Tue Oct 24 21:28:00 2006
          State : dirty, no-errors
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
 
 
    Number   Major   Minor   RaidDevice State
       0      22        1        0      active sync   /dev/hdc1
       1      22       65        1      active sync   /dev/hdd1
           UUID : 463dfe4b:903e3a5e:be876c16:653cc561

建立軟體磁碟陣列方法

  • 透過安裝 CentOS 過程中選擇建立 SoftRAID FIXME

使用命令列詳細過程

  • 將 hda1 與 hdc1 建立為 raid1 的 md0 語法
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/hda1 /dev/hdc1
  • 查看 md0 建立的狀況
# cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 hda1[0] hdc1[1] 56261376 blocks [2/2] [UU]

出現 RAID 異常切換方法

  • md0 發生異常時的狀況:
# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb2[1] sda2[0]
      4297280 blocks [2/2] [UU]

md0 : active raid1 sdb1[1]
      235520832 blocks [2/1] [_U] 
  • 將 md0 內出問題的 sda1 移除
# mdadm /dev/md0 --remove /dev/sda1
mdadm: hot removed /dev/sda1
  • 當 sda 更換好之後,再將 sda1 加回 md0 內
# mdadm /dev/md0 --add /dev/sda1
mdadm: hot added /dev/sda1
  • 這時會看到加回 md0 的狀況
# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb2[1] sda2[0]
      4297280 blocks [2/2] [UU]

md0 : active raid1 sda1[2] sdb1[1]
      235520832 blocks [2/1] [_U]
      [=>...................]  recovery =  6.4% (15183872/235520832)
finish=79.6min speed=46101K/sec
unused devices: 

參考網址

tech/softraid.txt · 上一次變更: 2009/03/03 01:13 由 jonathan