Linux implements the most commonly used disk array--RAID5

Source: Internet
Author: User
Tags disk usage

(a) Introduction to raid:
Redundant array of independent disks (RAID, redundant array of independent Disks), old Redundant array of inexpensive disks (raid,redundant array of Inexpensive Disks), abbreviated hard disk array. The basic idea is to combine a number of relatively inexpensive hard drives into a hard disk array to achieve even more expensive, large-capacity drives. Depending on the version selected, RAID has the benefit of one or more of the following aspects than a single hard drive: Enhanced data integration, enhanced fault tolerance, increased throughput or capacity. In addition, the disk array looks like a separate hard disk or logical storage unit for a computer. Divided into raid-0,raid-1,raid-1e,raid-5,raid-6,raid-7,raid-10,raid-50
In short, RAID combines multiple hard disks into a single logical sector, so the operating system only treats it as a hard disk. RAID is often used on server computers and is often combined using exactly the same hard drive. Due to the declining cost of hard drives and the more efficient integration of RAID features with the motherboard, it has become a choice for players, especially those that require large volumes of storage, such as video and audio production
The initial raid was divided into different levels, each with its theoretical advantages and disadvantages, with different levels balancing the two targets, increasing data reliability and increasing memory (group) Read and write performance. Over the years, there have been different applications for RAID concepts

RAID 5 is a storage solution that combines storage performance, data security, and storage costs. RAID 5 can be understood as a compromise between RAID 0 and RAID 1. RAID 5 has a similar data read speed as RAID 0, with only one parity information, which is slower than writing to a single disk. At the same time, because of multiple data corresponding to a parity information, RAID 5 disk space utilization is higher than RAID 1, the storage cost is relatively low, is a more application of a solution
(b) The difference between each soft raid:
RAID4, parity Backup, a minimum of 3 hard disks, one hard disk as a parity backup, then any piece of hard disk damage can be other disks and check disk through parity restore data
RAID5, distributed parity database to each hard disk, minimum 3 drives
RAID6, both horizontal and vertical parity, minimum 4 drives
RAID0, the fastest, not redundant, at least 2 hard drives, twice times faster (more hard drives, more theoretical speed), but any piece of hard disk damage, then all data scrap
raid1,50% redundancy;--raid0+1
(iii) the implementation of Linux RAID5 the parameters of the detailed instructions and notes:
Number of disks required: more than three blocks
Here we add four hard drives, of which 3 are disk arrays, 1 are ready (spare) disks
Note: RAID5 disk usage is N-1 that means four 30G of hard disk free space is 90G
Experimental steps:

  1. Check the disk devices in the system fdisk-l
  2. The next command to create the raid is Mdadm, if not, install the MDADM software package (Rpm-qa |grep mdadm) First
    Note: The RHEL 6.5 disc has
    Mdadm--create--auto=yes/dev/md0--level=5--raid-devices=3--spare-devices=1/dev/sd[b-e]

    Parameter explanation:
    --create//indicates to create raid
    --AUTO=YES/DEV/MD0//Whether automatic detection, the newly established software disk display device for the MD0,MD sequence number can be 0-9
    --LEVEL=5//disk array level, here is RAID5
    -raid-devices//number of disks to be used
    --spare-devices//Add the number of blocks as a prestaged (spare) disk
    /DEV/SD[B-E]//disk array used by the device, also can be written as "/DEV/SDB/DEV/SDC/DEV/SDD/DEV/SDE" can also be abbreviated as: Mdadm–c–a yes/dev/md0–l5–n3–x1/dev/sd[b -E]
    There are two ways to see if the raid was successful and whether the creation is working properly
  3. View more information: Mdadm--detail/dev/md0 command to view raid details

  4. More simple view: You can view the Cat/proc/mdstat files directly to see the raid running situation

    U means no problem, _ is not normal, the disk behind the (S) is indicated as a preliminary
    Format and mount and use raid created
    MKFS.EXT4/DEV/MD0//Format RAID5 disk as Md0

    Mkdir/raid
    Mount/dev/md0/raid//Mount the md0 to the/raid directory
    Check the Mount status
    Df–ht

    Try a new raid is not available, write files to it
    Set boot auto-start raid and auto Mount
    Let raid boot up, riad configuration file name is mdadm.conf, this file is not exist by default, to establish itself. The main function of this configuration file is to automatically load soft raid when the system starts up, and to manage it later. Note the following mdadm.conf files are mainly composed of:
    The devices option makes up all the devices that make up the raid
    The array option specifies the device name of the array, the RAID level, the number of active devices in the array, and the device's UUID number
    Note: If this file is not created after the next power-on reboot,/DEV/MD0 will be automatically recognized by the system as a non-/dev/md0 name device, which is inconvenient for booting and using.
    Auto-start raid
    First set up/etc/mdadm.conf this file
    Mdadm--detail--scan >/etc/mdadm.conf
    To make a change to this file: Append the device name that makes up RAID5 to the configuration file

    When setting up auto mount for raid
    Modify File Vi/etc/fstab
    Add a line/dev/md0/raid ext4 defaults 0 0
    Simulate disk corruption in the RAID5, verify the functionality of the spare disk (allowing damage to a piece of disk in RAID5, that is, the spare disk we set will immediately replace the broken disk for RAID reconstruction, ensuring data security)
    Mdadm--manage/dev/md0--FAIL/DEV/SDD//Use this command to set the status of SDD as an error (or to be abbreviated to MDADM/DEV/MD0-F/DEV/SDD)

    Check out the disk information: mdadm–-detail/dev/md0

Simply look at the raid scenario:

The completion of the creation means that RAID5 has been automatically restored!
Check to see if RAID5 is working properly!
Write data to the inside, it can be found that RAID5 can also be used normally, no impact on the data
True members of Active SYNC/DEV/SDB1 # raid
SPARE/DEV/SDC1 #raid备用成员
If you want to add/DEV/SDD into RAID5 again, do the following:
MDADM/DEV/MD0--REMOVE/DEV/SDD//will be broken disk SDD from raid
Mdadm/dev/md0-a/DEV/SDD//Adding/DEV/SDD to the array
Mdadm--zero-superblock--FORCE/DEV/SDD (optional)//repairable HDD re-added to simulate damaged hard drive
Command parameters
-A =--assemble active
-S =--stop stop
-D =--detail View raid details
-C =--Create a RAID device
-V =--verbose Show details of the build process
-L =--level RAID level
-n = number of--raid-devices RAID devices
-s =--scan Scan raid device
-F =--fail marked bad hard drive
-A =--add add hard drive
-r =-remove removing bad hard drive

How to turn off raid:

Uninstall the/dev/md0 directly and comment out the configuration in the/etc/fstab file
UMOUNT/DEV/MD0//Lift Hook up
Vi/etc/fstab//Fstab The inside of the boot automatically mount comments out
#/dev/md0/var/www/html EXT4 Defaults 0 0
Mdadm--stop/dev/md0//Stop MD0 Disk Service

Linux implements the most commonly used disk array--RAID5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.