Online Book Reader

Home Category

Managing RAID on Linux - Derek Vadala [52]

By Root 1370 0
replicates data across all member disks. This allows a RAID-1 to continue functioning even if a disk fails. The simplest RAID-1 configuration must contain at least two member disks. In this example, /dev/sdb1 and /dev/sdc1 are member disks of the RAID-1 at /dev/md0:

# A RAID-1 with two member disks

raiddev /dev/md0

raid-level 1

nr-raid-disks 2

chunk-size 64

device /dev/sdb1

raid-disk 0

device /dev/sdc1

raid-disk 1

chunk-size has no effect on RAID-1 because no disk striping is involved. But chunk-size is still required as a placeholder. Note also that the persistent-superblock isn't needed for RAID-1. Use mkraid to create this array:

# mkraid /dev/md0

handling MD device /dev/md0

analyzing super-block

disk 0: /dev/sdb1, 17920476kB, raid superblock at 17920384kB

disk 1: /dev/sdc1, 17920476kB, raid superblock at 17920384kB

Or, using mdadm:

# mdadm -Cv -l1 -n2 /dev/md0 /dev/sd{b,c}1

mdadm: array /dev/md0 started.

Whenever a new mirror is created, resynchronization occurs:

# cat /proc/mdstat

Personalities : [linear] [raid0] [raid1] [raid5]

read_ahead 1024 sectors

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

17920384 blocks [2/2] [UU]

[= = = = = = = =>............] resync = 40.2% (7212864/17920384)

finish=6.4min speed=27652K/sec

unused devices:

Now /proc/mdstat reports information about the array and also includes information about the resynchronization process. Resynchronization takes place whenever a new array that supports data redundancy is initialized for the first time. The resynchronization process ensures that all disks in a mirror contain exactly the same data.

The resynchronization is about 40 percent done and should be completed in less than six and a half minutes. You can begin creating a filesystem on the array even before resynchronization completes, but you probably shouldn't put the array into production until it finishes.

Once the initial synchronization is complete, the progress bar no longer appears in /proc/mdstat:

# cat /proc/mdstat

Personalities : [linear] [raid0] [raid1] [raid5]

read_ahead 1024 sectors

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

17920384 blocks [2/2] [UU]

unused devices:

When a disk does fail, it's useful to be able to automatically promote another disk into the array to replace the failed disk. When using raidtools, the nr-spare-disks and spare-disk parameters are used to define additional fault tolerance features. nr-spare-disks defines the number of extra, unused disks that the array can use to replace failed disks. It's also important to note that the sequence of spare disks begins with zero and is not an offset of the nr-raid-disks variable. The spare-disk parameter is combined with the device parameter to define disks that will be inserted into the array when a member disk fails. In this example, we still have a two-disk mirror consisting of /dev/sdb1 and /dev/sdc1. But this time, a spare disk (/dev/sdd1) is also specified.

# A RAID-1 with 2 member disks and 1 spare disk

raiddev /dev/md0

raid-level 1

chunk-size 64

nr-raid-disks 2

nr-spare-disks 1

device /dev/sdb1

raid-disk 0

device /dev/sdc1

raid-disk 1

device /dev/sdd1

spare-disk 0

Create an array using this /etc/raidtab file with mkraid:

# mkraid /dev/md0

handling MD device /dev/md0

analyzing super-block

disk 0: /dev/sdb1, 1614501kB, raid superblock at 1614400kB

disk 1: /dev/sdc1, 1614501kB, raid superblock at 1614400kB

disk 2: /dev/sdd1, 1614501kB, raid superblock at 1614400kB

If you are using mdadm, the -x flag defines the number of spare disks. Member disks are parsed from left to right on the command line. Thus, the first two disks listed in this example (/dev/sdb1 and /dev/sdc1) become the active RAID members, and the last disk (/dev/sdd1) becomes the spare disk.

# mdadm -Cv -l1 -n2 -x1 /dev/md0 /dev/sd{b,c,d}1

mdadm: array /dev/md0 started.

If a disk in this array failed, the kernel would remove the failed drive (either /dev/sdb1 or /dev/sdc1) from /dev/md0, insert /dev/sdd1 into the array and start reconstruction. In this case /dev/sdc1 has failed, as indicated

Return Main Page Previous Page Next Page

®Online Book Reader