Linux Learning-Software disk array settings (MDADM)

Source: Internet
Author: User

Software RAID--disk array with hardware disk array and software disk array, hardware disk array using disk array card to achieve effect, so that multiple disks to form a large disk, to the operating system, only see this large disk but not see those small disk, but the disk array cards expensive, Ordinary users in the learning process can not implement hardware disk array, so there is the use of software to implement the disk array function, the operating system will be a number of small disks to form a large virtual disk, while the operating system can see each small disk.

Directory

    • Software RAID Creation (Mdadm--create |-c)

    • Software RAID emulation error (Mdadm--manage)

    • How to mount raid on boot

    • How to shut down raid completely

    • Implementation of shared Hot spares

    • Case

****************** creation of a software RAID (Mdadm--create|-c)********************

~]# Mdadm-c-a yes/dev/md0-n 2-l 0/dev/sdc/dev/sdd~]# mdadm-c-a yes/dev/md1-n 2-l 1/dev/sde/dev/sdf~]# mdadm -c-a yes/dev/md1-n 2-l 1-x 1/dev/sd{e,f,g}

-C Create raid

-a yes automatically creates a subsequent RAID device/dev/mdx

The number of disks in the-N (--raid-devices=) num Array

Number of-X (--spare-devices=) num Hot Spares

-L (--level=) [015] Sets the level of the disk array, typically RAID 0,raid 1,raid 5

Finally, each disk used to create the disk array must be listed

~]# mdadm-d/dev/md0

-D (--detail) followed by the set disk array appliance name, view raid information


also Cat/proc/mdstat You can view all the raid information

****************** two software RAID emulation error (Mdadm--manage) ******************

Mdadm (--manage)/dev/md1-f/dev/sdf the md1 in the SDF set as a bad device,--manage add no matter, the same

Mdadm (--manage) /dev/md1-r/dev/sdf remove SDF from RAID member in MD1

Mdadm (--manage) /dev/md1-a/dev/sdf Add new member SDF to MD1

Mdadm-g/dev/md1-n 3-a/DEV/SDH Change the number of RAID1 MD1 members to 3 and add new members (not add to hot spare)


You can see that the function of-A is:

Changes in the value of the Raid-devices=num based on the start of the raid setting;

If the NUM disks in the raid are intact,- a just adds the hot spare

If the number of disks that can be used in a raid is insufficient num,-a will complement the composition Raid-device

three how to mount raid *************************** on boot

it as with the previous disk partition mount, RAID is treated as a disk .

1 Modifying the RAID configuration file /etc/mdadm.conf

Mdadm-d-s > /etc/mdadm.conf

2 Modifying the configuration file/etc/fstab (I'm sure you're familiar with it)

/dev/md0/mnt/raid EXT4 Defaults 1 2

Add the above line to the configuration file

3 Mounting Mount-a

View after reboot

four how to completely shut down raid****************************

Mdadm-s (--stop)/dev/md0 stop raid

Mdadm-a/DEV/MD0/DEV/SDC/DEV/SDD/DEV/SDE Open raid

Mdadm-d-S

Mdadm-d-s > /etc/mdadm.conf to save RAID information to this file

Mdadm-a-S automatically activates all RAID devices in the/etc/mdadm.conf

-------------------------------------------------------------------------------

a method that completely shuts down the raid and then no longer activates :

mdadm-s/dev/mdx

Remove the content from the /etc/mdadm.conf

mdadm--zero-superblock/dev/sdm (RAID device) key

**************************** five shared hot spares implementation ****************************

# Create RAID 1 and RAID 5, where only RAID 5 has a hot spare ~]# mdadm-c--auto=yes/dev/md0-n 2-l 1/dev/sd{c,d}~]# mdadm-c--auto=yes/dev/md1-n 3-x 1-l 5/dev/sd{e. H

Enables the use of only one hot spare between/dev/md0 and/DEV/MD1

①mdadm-d-S >/etc/mdadm.conf

② spare-group= Any number of RAID information that needs to be shared at the end of each

③ then adds a new line, the head writes Mailaddr. (Be sure to have a space)

④service Mdmonitor Start

⑤ Test

View the status of the previous two raid

# damage to disk/DEV/SDC in/dev/md0 (note that there is no hot spare in/dev/md0) ~]# mdadm/dev/md0-f/DEV/SDCMDADM:SET/DEV/SDC Faulty in/dev/md0

Result/DEV/MD1 the hot spare/DEV/SDH automatically replace the damaged/DEV/SDC under/dev/md0

* * * * * * * six case * * * * *********************************

1: Create a RAID1 device with free space of 1G, file system is EXT4, boot can automatically mount to the/backup directory

New two 1G-size hdd echo '---' >/sys/class/scsi_host/host0/scanlsblk or cat/proc/partitions or Ll/dev/sd*mdadm--create--a uto=yes/dev/md0--level 1-n 2/dev/sd{c,d}mdadm-d/dev/md0mkfs.ext4/dev/md0blkid/dev/md0mkdir/backupmount/dev/md0/b Ackup

2: Create a RAID5 device consisting of three hard drives with 2G of free space, requiring its chunk size 256k, file system is EXT4, boot can automatically mount to/mydata directory

Newly created three 2G-size HDD echo '---' >/sys/class/scsi_host/host0/scanmdadm--create--auto=yes/dev/md1--level=5--chunk=256k-n 3/dev/sd{e,f,g}mkfs.ext4/dev/md1mkdir/mydata Mount/dev/md1/mydata


Linux Learning-Software disk array settings (MDADM)

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.