The most common Linux implementation of disk arrays - RAID5

(A) RAID Profile:

A redundant array of independent disks (RAID, Redundant Array of Independent Disks), formerly known as redundant array of inexpensive disks (RAID, Redundant Array of Inexpensive Disks), referred to as disk arrays. The basic idea is to put a number of relatively inexpensive hard drives combined into a disk array group, the performance meets or exceeds a high price, huge capacity hard disk. Depending on the selected version, RAID has one or more of the following benefits than one hard drive: Enhanced Data integration, enhanced fault tolerance, or increasing the amount of processing capacity. Further, the disk array for the computer, it looks like a single logical storage unit or a hard disk. Into RAID-0, RAID-1, RAID-1E, RAID-5, RAID-6, RAID-7, RAID-10, RAID-50.

Simply put, RAID hard drives combined into a plurality of logical sectors, therefore, the operating system would treat it like a hard disk. RAID is often used on the server computer, and the same hard disk as often used in combination. Due to the hard disk prices continue to decline with RAID function more effectively integrated with the motherboard, it has also become a choice of players, in particular the need for high capacity storage space, such as: video and audio production.

The initial RAID divided into different levels, each level has its theoretical advantages and disadvantages, different levels strike a balance between two objectives, namely, to increase data reliability and increased memory (cluster) read and write performance. Over the years, the emergence of the concept of RAID for different applications.

clip_image002 clip_image004

clip_image006

clip_image008 clip_image010

(B) linux to achieve soft RAID5:

1, to prepare the hard drive (requires at least three hard drives, where one disk partition to achieve the 5, but in the actual production of hard disk RAID do not make sense):

[Root @ localhost ~] # fdisk -cul / dev / sdb # create partitions as follows

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x466fc1b6

Device Boot Start End Blocks Id System

/dev/sdb1 2048 10487807 5242880 83 Linux

/dev/sdb2 10487808 41943039 15727616 5 Extended

/dev/sdb5 10489856 16781311 3145728 83 Linux

/dev/sdb6 16783360 23074815 3145728 83 Linux

/dev/sdb7 23076864 29368319 3145728 83 Linux

/dev/sdb8 29370368 35661823 3145728 83 Linux

/dev/sdb9 35663872 41943039 3139584 83 Linux

[Root @ localhost ~] # partx -a / dev / sdb # reread partition table

[Root @ localhost ~] # rpm -qa | grep mdadm # View software is installed to create a raid

mdadm-3.2.3-9.el6.i686

2, create a RAID5:

[Root @ localhost ~] # mdadm -C / dev / md0 -a yes -l 5 -n 4 -x 1 /dev/sdb{5..9} #### - C: Create / dev / md0 device, -a: whether to automatically detect here is yes, -l: raid level here raid5, -n: a few hard drives as RUN, -x: a few hard drives as a backup

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.

[Root @ localhost ~] # mdadm --detail / dev / md0 # to view details / dev / md0 of

/dev/md0:

Version : 1.2

Creation Time : Mon Jan 14 19:36:37 2013

Raid Level : raid5

Array Size : 9414144 (8.98 GiB 9.64 GB)

Used Dev Size : 3138048 (2.99 GiB 3.21 GB)

Raid Devices : 4

Total Devices : 5

Persistence : Superblock is persistent

Update Time : Mon Jan 14 19:37:27 2013

State : clean

Active Devices : 4

Working Devices : 5

Failed Devices : 0

Spare Devices : 1

Layout : left-symmetric

Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)

UUID : f16324c8:0f2a0be2:04c57c07:5f44f53e

Events : 18

Number Major Minor RaidDevice State

0 8 21 0 active sync /dev/sdb5

1 8 22 1 active sync /dev/sdb6

2 8 23 2 active sync /dev/sdb7

5 8 24 3 active sync /dev/sdb8

4 8 25 - spare /dev/sdb9

3, formatting, loading, use / dev / md0:

[Root @ localhost ~] # mkfs.ext4 / dev / md0 # a / dev / md0 formatted

[Root @ localhost ~] # mkdir / raid5 ## Create a mount directory

[Root @ localhost ~] # the mount / dev / md0 / raid5 / # mount / dev / md0 to / raid5 directory

[root@localhost ~]# cd /raid5/

[root@localhost raid5]# touch raid5.file

[root@localhost raid5]# ls

lost+found raid5.file

4, set the boot RAID5:

[Root @ localhost ~] # mdadm --detail --scan # View brief information about raid

ARRAY /dev/md0 metadata=1.2 spares=1 name=localhost.localdomain:0 UUID=f16324c8:0f2a0be2:04c57c07:5f44f53e

[Root @ localhost ~] # mdadm --detail --scan> /etc/mdadm.conf # create soft raid profile! Note: If you do not create this file after the next power-on reset / dev / md0 will be automatically recognized as other non-device / dev / md0 name, it is not easy to achieve power to mount and use.

[Root @ localhost ~] # vim / etc / fstab # fstab file editor add the following lines

/dev/md0 /raid5 ext4 defaults 0 0

4, management RAID5:

View raid's status:

[Root @ localhost ~] # cat / proc / mdstat # Check status raid

Personalities : [raid6] [raid5] [raid4]

md0 : active raid5 sdb8[5] sdb94 sdb7[2] sdb6[1] sdb5[0]

9414144 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]

unused devices: <none>

View details of a specific raid device:

[root@localhost ~]# mdadm --detail /dev/md0

................................................... omitted ...................................................... ..

Number Major Minor RaidDevice State

0 8 21 0 active sync /dev/sdb5

1 8 22 1 active sync /dev/sdb6

2 8 23 2 active sync /dev/sdb7

5 8 24 3 active sync /dev/sdb8

4 8 25 - spare /dev/sdb9

Analog hard disk damage:

[Root @ localhost ~] # mdadm / dev / md0 --fail / dev / sdb5 # simulated hard disk corruption

[root@localhost ~]# mdadm –detail #验证

................................................... omitted ...................................................... ..

Name : localhost.localdomain:0 (local to host localhost.localdomain)

UUID : f16324c8:0f2a0be2:04c57c07:5f44f53e

Events : 25

Number Major Minor RaidDevice State

4 8 25 0 spare rebuilding /dev/sdb9

1 8 22 1 active sync /dev/sdb6

2 8 23 2 active sync /dev/sdb7

5 8 24 3 active sync /dev/sdb8

0 8 21 - faulty spare /dev/sdb5

State #### / dev / sdb5 became faulty, / dev / sdb9 immediately becomes active

Analog pull out the hard drive:

[Root @ localhost ~] # mdadm / dev / md0 --remove / dev / sdb5 # analog pulled hard

mdadm: hot removed /dev/sdb5 from /dev/md0

[root@localhost ~]# mdadm –detail #验证

................................................... omitted ...................................................... ..

Name : localhost.localdomain:0 (local to host localhost.localdomain)

UUID : f16324c8:0f2a0be2:04c57c07:5f44f53e

Events : 4

Number Major Minor RaidDevice State

4 8 25 0 active sync /dev/sdb9

1 8 22 1 active sync /dev/sdb6

2 8 23 2 active sync /dev/sdb7

5 8 24 3 active sync /dev/sdb8

#### / dev / sdb5 has disappeared from / dev / md0 in the:

Add the hard disk to simulate the raid:

[Root @ localhost ~] # mdadm --zero-superblock --force / dev / sdb5 # repair the hard disk

[Root @ localhost ~] # mdadm / dev / md0 --add / dev / sdb5 # Add the hard disk to simulate the raid

mdadm: added /dev/sdb5

[root@localhost ~]# mdadm --detail /dev/md0 #验证

/dev/md0:

Version : 1.2

Creation Time : Mon Jan 14 19:36:37 2013

Raid Level : raid5

Array Size : 9414144 (8.98 GiB 9.64 GB)

Used Dev Size : 3138048 (2.99 GiB 3.21 GB)

Raid Devices : 4

Total Devices : 5

Persistence : Superblock is persistent

Update Time : Mon Jan 14 20:17:02 2013

State : clean

Active Devices : 4

Working Devices : 5

Failed Devices : 0

Spare Devices : 1

Layout : left-symmetric

Chunk Size : 512K

Name : localhost.localdomain:0 (local to host localhost.localdomain)

UUID : f16324c8:0f2a0be2:04c57c07:5f44f53e

Events : 41

Number Major Minor RaidDevice State

4 8 25 0 active sync /dev/sdb9

1 8 22 1 active sync /dev/sdb6

2 8 23 2 active sync /dev/sdb7

5 8 24 3 active sync /dev/sdb8

6 8 21 - spare /dev/sdb5

#### / dev / sdb5 been successfully added to the / dev / md0 and are waiting to use the device as a backup.

Guess you like

Origin blog.51cto.com/14380057/2409731