Software raid 5, software raid

Source: Internet
Author: User

Software raid 5, software raid

Implementation of Software raid 5

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 can provide data security for the system, but it is more secure than Mirror, and the disk space utilization is higher than Mirror. RAID 5 has a Data Reading Speed similar to RAID 0, but has an additional parity information. The data writing speed is slightly slower than that of a single disk. At the same time, because multiple pieces of data correspond to one parity information, the disk space utilization of RAID 5 is higher than that of RAID 1, and the storage cost is relatively low. This is a solution that is widely used at present.

1 partition

Here, two hard disks are used:/dev/sda8 and/dev/sda9, And/dev/sdb and/dev/sdc.

Note: Change the partition ID to fd.

2 create raid 5

mdadm -C /dev/md5 -a yes -l 5 -n 3 -x 1 /dev/sdd1 /dev/sde1 /dev/sdf /dev/sdb2
[root@centos7 ~]# mdadm -C /dev/md5 -a yes -l 5 -n 3 -x 1 /dev/sda8 /dev/sda9 /dev/sdb /dev/sdcmdadm: Defaulting to version 1.2 metadatamdadm: array /dev/md5 started.

-C Creation Mode

-N #: Use # Fast devices to create RAID

-L #: indicates the level of the RAID to be created.

-A {yes | no}: automatically creates the device file of the target RAID device.

-C CHUNK_SIZE: indicates the block size.

-X #: specifies the number of backup disks. The default value is the number of backup disks.

3. Create a File System

[root@centos7 ~]# mkfs.ext4 /dev/md5

4 Mount

(1) create a mount directory

[root@centos7 ~]# mkdir /mnt/raid5

(2) Mounting

[root@centos7 ~]# mount /dev/md5 /mnt/raid5

5. Generate a configuration file

[root@centos7 ~]# cat /etc/mdadm.confARRAY /dev/md5 metadata=1.2 spares=1 name=centos7.3.loacl:5 UUID=5ec4115c:ab1e25c8:ff36d8a2:74f6fd8a

View the md status

[root@centos7 ~]# cat /proc/mdstatPersonalities : [raid0] [raid6] [raid5] [raid4]md5 : active raid5 sdb[4] sdc[3](S) sda9[1] sda8[0]2095104 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

View raid details

[root@centos7 ~]# mdadm -D /dev/md5/dev/md5:Version : 1.2Creation Time : Tue Apr 25 14:38:54 2017Raid Level : raid5Array Size : 2095104 (2046.00 MiB 2145.39 MB)Used Dev Size : 1047552 (1023.00 MiB 1072.69 MB)Raid Devices : 3Total Devices : 4Persistence : Superblock is persistentUpdate Time : Tue Apr 25 14:50:08 2017State : cleanActive Devices : 3Working Devices : 4Failed Devices : 0Spare Devices : 1Layout : left-symmetricChunk Size : 512KName : centos7.3.loacl:5 (local to host centos7.3.loacl)UUID : 5ec4115c:ab1e25c8:ff36d8a2:74f6fd8aEvents : 18Number Major Minor RaidDevice State0 8 8 0 active sync /dev/sda81 8 9 1 active sync /dev/sda94 8 16 2 active sync /dev/sdb3 8 32 - spare /dev/sdc

You can see the expected combination of three active devices and one idle (standby) device.

6. Disable and enable

umount /mnt/raid0mdadm -S /dev/md0mdadm -A /dev/md0

(1) Disable raid

[root@centos7 ~]# umount /mnt/raid5[root@centos7 ~]# mdadm -S /dev/md5mdadm: stopped /dev/md5

Check that the instance has been stopped successfully.

[root@centos7 ~]# mdadm -D /dev/md5mdadm: cannot open /dev/md5: No such file or directory

(2) Enable raid Devices

[root@centos7 ~]# mdadm -A /dev/md5mdadm: /dev/md5 has been started with 3 drives and 1 spare.

Check again and find that the instance has been started successfully.

[root@centos7 ~]# cat /proc/mdstatPersonalities : [raid0] [raid6] [raid5] [raid4]md5 : active raid5 sda8[0] sdc[3](S) sdb[4] sda9[1]2095104 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

7 simulate/dev/sdc corruption

[root@centos7 ~]# mdadm /dev/md5 -f /dev/sdcmdadm: set /dev/sdc faulty in /dev/md5

8 Remove/dev/sdc

[Root @ centos7 ~] # Mdadm/dev/md5-r/dev/sdcmdadm: hot removed/dev/sdc from/dev/md5 [root @ centos7 ~] # Mdadm-D/dev/md5/dev/md5: […] Active Devices: 3 Working Devices: 3 Failed Devices: 0 Spare Devices: 0 […] Number Major Minor RaidDevice State0 8 8 0 active sync/dev/sda81 8 9 1 active sync/dev/sda94 8 16 2 active sync/dev/sdb

You can see that the removal is successful.

Let's take a look at the disk situation.

[root@centos7 ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTfd0 2:0 1 4K 0 disksda 8:0 0 20G 0 disk[……]├─sda8 8:8 0 1G 0 part│ └─md5 9:5 0 2G 0 raid5└─sda9 8:9 0 1G 0 part└─md5 9:5 0 2G 0 raid5sdb 8:16 0 1G 0 disk└─md5 9:5 0 2G 0 raid5sdc 8:32 0 1G 0 disksr0 11:0 1 7.7G 0 rom

We can see that/dev/sdc is no longer an md5 array.

9 add to a raid Member

[root@centos7 ~]# mdadm /dev/md5 -a /dev/sdcmdadm: added /dev/sdc
[root@centos7 ~]# mdadm -D /dev/md5/dev/md5:[……]Raid Devices : 3Total Devices : 4Active Devices : 3Working Devices : 4[……]Number Major Minor RaidDevice State0 8 8 0 active sync /dev/sda81 8 9 1 active sync /dev/sda94 8 16 2 active sync /dev/sdb3 8 32 - spare /dev/sdc

You can see that the instance is successfully added.

10 increase the number of raid members from 3 to 4

Add the device/dev/sdd to the array.

[root@centos7 ~]# mdadm -G /dev/md5 -n 4 -a /dev/sddmdadm: added /dev/sddmdadm: Need to backup 3072K of critical section..

Check file system integrity

[root@centos7 ~]# e2fsck -f /dev/md5e2fsck 1.42.9 (28-Dec-2013)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/md5: 11/131072 files (0.0% non-contiguous), 17964/523776 blocks

Synchronize file systems

[root@centos7 ~]# resize2fs /dev/md5resize2fs 1.42.9 (28-Dec-2013)Resizing the filesystem on /dev/md5 to 785664 (4k) blocks.The filesystem on /dev/md5 is now 785664 blocks long.

Check the/dev/md5 array.

[root@centos7 ~]# mdadm -D /dev/md5/dev/md5:Version : 1.2Creation Time : Tue Apr 25 14:38:54 2017Raid Level : raid5Array Size : 3142656 (3.00 GiB 3.22 GB)Used Dev Size : 1047552 (1023.00 MiB 1072.69 MB)Raid Devices : 4Total Devices : 5Persistence : Superblock is persistentUpdate Time : Tue Apr 25 15:13:32 2017State : cleanActive Devices : 4Working Devices : 5Failed Devices : 0Spare Devices : 1 Layout : left-symmetricChunk Size : 512KName : centos7.3.loacl:5 (local to host centos7.3.loacl)UUID : 5ec4115c:ab1e25c8:ff36d8a2:74f6fd8aEvents : 47Number Major Minor RaidDevice State0 8 8 0 active sync /dev/sda81 8 9 1 active sync /dev/sda94 8 16 2 active sync /dev/sdb5 8 48 3 active sync /dev/sdd3 8 32 - spare /dev/sdc

Related Article

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.