Thursday 2 January 2014

RAID (Redundant Array of Independent Disks) in Linux with Practical

RAID (Redundant Array of Independent Drives (or Disks)
A. A Redundant Array of Independent Drives (or Disks), also known as Redundant Array of Inexpensive Drives (or Disks) (RAID) is an term for data storage schemes that divide and/or replicate data among multiple hard drives. RAID can be designed to provide increased data reliability or increased I/O performance, though one goal may compromise the other.

Mainly there are 3 types of RAID :

RAID  0
RAID  1
RAID  5



RAID 0 (Striping)
This level is achieved by grouping 2 or more hard disks into a single unit with the total size equaling that of all disks used. Practical example: 3 disks, each 80GB in size can be used in a 240GB RAID 0 configuration.

RAID 0 works by breaking data into fragments and writing to all disk simultaneously. This significantly improves the read and write performance. On the other hand, no single disk contains the entire information for any bit of data committed. This means that if one of the disks fails, the entire RAID is rendered inoperable, with unrecoverable loss of data.

RAID 0 is suitable for non-critical operations that require good performance, like the system partition or the /tmp partition where lots of temporary data is constantly written. It is not suitable for data storage.



RAID 1 (Mirroring)

This level is achieved by grouping 2 or more hard disks into a single unit with the total size equaling that of the smallest of disks used. This is because RAID 1 keeps every bit of data replicated on each of its devices in the exactly same fashion, create identical clones. Hence the name, mirroring. Practical example: 2 disks, each 80GB in size can be used in a 80GB RAID 1 configuration. On a side note, in mathematical terms, RAID 1 is an AND function, whereas RAID 0 is an OR.

Because of its configuration, RAID 1 reduced write performance, as every chunk of data has to be written n times, on each of the paired devices. The read performance is identical to single disks. Redundancy is improved, as the normal operation of the system can be maintained as long as any one disk is functional. RAID 1 is suitable for data storage, especially with non-intensive I/O tasks.






RAID 5

This is a more complex solution, with a minimum of three devices used. Two or more devices are configured in a RAID 0 setup, while the third (or last) device is a parity device. If one of the RAID 0 devices malfunctions, the array will continue operating, using the parity device as a backup. The failure will be transparent to the user, save for the reduced performance.

RAID 5 improves the write performance, as well as redundancy and is useful in mission-critical scenarios, where both good throughput and data integrity are important. RAID 5 does induce a slight CPU penalty due to parity calculations.





PRACTILE  OF RAID USING RAID 1
First create 3 partitions sda10,sda11,sda12 of raid type
[root@www ~]# mdadm -C /dev/md0 -l 1 -n 2 /dev/md10 /dev/md11
C-- create
l-- level
n-- numder of device
[root@www ~]# mdadm --detail /dev/md0
[root@www ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Sun Jan 13 22:11:49 2013
     Raid Level : raid1
     Array Size : 104320 (101.89 MiB 106.82 MB)
  Used Dev Size : 104320 (101.89 MiB 106.82 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Jan 13 22:24:07 2013
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 63a6d6db:ced50964:3fb69cfe:6b30dd55
         Events : 0.6


    Number   Major   Minor   RaidDevice State
       0       8       10        0      active sync   /dev/sda10
       1       8       12        1      active sync   /dev/sda11

      

[root@www ~]# mkfs.ext3 /dev/md0
[root@www ~]# mkdir /raid
[root@www ~]# mount /dev/md0 /raid
now add a spare device
[root@www ~]# mdadm --add /dev/md0 /dev/md12
/dev/md0:
        Version : 00.90.03
  Creation Time : Sun Jan 13 22:11:49 2013
     Raid Level : raid1
     Array Size : 104320 (101.89 MiB 106.82 MB)
  Used Dev Size : 104320 (101.89 MiB 106.82 MB)
   Raid Devices : 2
  Total Devices : 3
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Jan 13 22:24:07 2013
          State : clean
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

           UUID : 63a6d6db:ced50964:3fb69cfe:6b30dd55
         Events : 0.6

    Number   Major   Minor   RaidDevice State
       0       8       10        0      active sync   /dev/sda10
       1       8       11        1      active sync   /dev/sda11
       2       8       12        2      spare sync   /dev/sda12
[root@www ~]# cp -rvf /etc /raid
[root@www ~]# mdadm --fail /dev/md0 /dev/sda11
[root@www ~]#  Used Dev Size : 104320 (101.89 MiB 106.82 MB)
   Raid Devices : 2
  Total Devices : 3
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Jan 13 22:23:54 2013
          State : clean, degraded, recovering
 Active Devices : 1
Working Devices : 2
 Failed Devices : 1
  Spare Devices : 1

 Rebuild Status : 50% complete

           UUID : 63a6d6db:ced50964:3fb69cfe:6b30dd55
         Events : 0.4

    Number   Major   Minor   RaidDevice State
       0       8       10        0      active sync   /dev/sda10
       2       8       12        1      spare rebuilding   /dev/sda12

       3       8       11        -      faulty spare   /dev/sda11

[root@www ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Sun Jan 13 22:11:49 2013
     Raid Level : raid1
     Array Size : 104320 (101.89 MiB 106.82 MB)
  Used Dev Size : 104320 (101.89 MiB 106.82 MB)
   Raid Devices : 2
  Total Devices : 3
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Jan 13 22:23:54 2013
          State : clean, degraded, recovering
 Active Devices : 1
Working Devices : 2
 Failed Devices : 1
  Spare Devices : 1

 Rebuild Status : 94% complete

           UUID : 63a6d6db:ced50964:3fb69cfe:6b30dd55
         Events : 0.4

    Number   Major   Minor   RaidDevice State
       0       8       10        0      active sync   /dev/sda10
       2       8       12        1      spare rebuilding   /dev/sda12

       3       8       11        -      faulty spare   /dev/sda11








No comments:

Post a Comment