Linux Learning note raid Introduction, and CENTOS6 on the implementation of soft raid

Source: Internet
Author: User
Tags deprecated hex code

The raid:redundant Arrays of inexpensive disk is an inexpensive redundant array of disks that can be organized in different ways to improve IO capabilities, or improve durability, for multiple hard drives. RAID can be divided into soft raid and hard raid, soft raid through software implementation, hard raid using professional RAID card and disk composition.


RAID Level: Multiple disk organizations work together in different ways. The common RAID level is RAID0,RAID1,RAID2,RAID3,RAID4,RAID5,RAID6,RAID10,RAID01.

raid0:striping striped data, stored to not multiple drives

Improved read and write performance

Free space: N disk space (limited by minimum disk space)

No fault tolerance, any piece of equipment is bad, will lead to data loss

Minimum number of disks: 2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/75/wKioL1XkRT7T_sP1AACfFmfEk40967.jpg "title=" Raid0.png "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:200px;height:200px; "alt=" Wkiol1xkrt7t_sp1aacffmfek40967.jpg "/>

RAID1: Mirrored raid

read performance improvement, write performance slightly decreased;

free Space: capacity of a disk with less capacity

redundant capability, single disk corruption, no data loss

Minimum number of disks: 2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/75/wKioL1XkRk-DOpYqAAOBEydLncw446.jpg "title=" Raid1.png "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:200px;height:200px; "alt=" Wkiol1xkrk-dopyqaaobeydlncw446.jpg "/>

RAID4: Use a disk to store the checksum code specifically

Read, write performance is improved

free Space: (N-1) * Minimum disk capacity

Fault tolerance: 1 disks can be broken

Minimum number of disks: 3

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/78/wKiom1XkRJzTIk5EAAEHe7YYfzY840.jpg "title=" Raid4.jpg "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:300px;height:300px; "alt=" Wkiom1xkrjztik5eaaehe7yyfzy840.jpg "/>

RAID5:

Read, write performance is improved

free Space: (N-1) * Minimum disk capacity

Fault tolerance: 1 disks can be broken

Minimum number of disks: 3

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/79/wKiom1XkRQORzQdqAABzgHF6ghg795.gif "title=" Rid5.gif "width=" "height=" 181 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:300px;height:181px; "alt=" Wkiom1xkrqorzqdqaabzghf6ghg795.gif "/>

RAID6: Two copies of the information stored: will result in more wasted disk space

Improved read and write performance

free Space: (N-2) * Minimum disk capacity

fault tolerance: up to 2 disk damage

Minimum number of disks: 4

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" background:url ("/E /u261/lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/> 650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/79/wKiom1XkRSXzqaGiAAEIscRt75Y460.jpg "title=" Raid6.png " alt= "Wkiom1xkrsxzqagiaaeiscrt75y460.jpg"/>

RAID10:

Improved reading and writing system performance

Free disk space: 50%

Fault tolerance: No group up to a bad piece of disk

Minimum number of disks: 4

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/76/wKioL1XkR7PCV9Z1AAC5uhtKhSE446.jpg "title=" Raid10.png "alt=" Wkiol1xkr7pcv9z1aac5uhtkhse446.jpg "/>

Other:

Jbod:just a bunch of disks.

Function: The space of multiple disks is combined with a large continuous space;

Free space: sum (s1,s2,...)

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

implementation of software RAID on CentOS 6 :

combined with MD (multi devices) in the kernel

Mdadm: a modular tool

syntax format for commands: mdadm [mode] <raiddevice> [options] <component-devices>

supported RAID levels: LINEAR, RAID0, RAID1, RAID4, RAID5, RAID6, RAID10;

Mode:

Create:-C

Assembly:-A

monitoring:-F

Management:-F,-R,-a

<raiddevice>:/dev/md#

<component-devices>: any block device

-C: Create pattern

-N #: Create this raid with # blocks of devices;

-L #: Indicates the level of RAID to be created;

-a {Yes|no}: Automatically create device files for target RAID devices;

- C Chunk_size: Indicates the block size;

-X #: Indicates the number of free disks;


Exercise: Create a RAID5 of 10G free space and leave a spare disk for hot standby

Step one: Use the Fdisk command to divide 4 5G partitions, 3 to make RAID5, and the other to make a bit free disk

[Email protected] ~]# fdisk/dev/sdb

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to

Switch off the mode (command ' C ') and change display units to

Sectors (Command ' u ').

Command (M for help): n #创建新分区

Command Action

E Extended

P primary partition (1-4)

P

Partition number (1-4): 1

First cylinder (1-15665, default 1):

Using Default value 1

Last cylinder, +cylinders or +size{k,m,g} (1-15665, default 15665): +5g

...

...

Repeat this previous step until you have created 4 required partitions: you need to be aware of changing the partition ID to FD format, and you can use the FDISK command to modify the following steps.

[Email protected] ~]# Fdisk/dev/sdb

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to

Switch off the mode (command ' C ') and change display units to

Sectors (Command ' u ').

Command (M for help): t #x修改分区id

Partition number (1-5): 1

Hex code (type L to list codes): fd #选择RARID所需的分区id

Command (M for help): w #保存修改

The partition table has been altered!


Step two: Format the partition

All the partitions have been created, and the effect is as follows

[Email protected] ~]# fdisk-l/dev/sdb #查看分区情况

disk/dev/sdb:128.8 GB, 128849018880 bytes

255 heads, Sectors/track, 15665 cylinders

Units = Cylinders of 16065 * 8225280 bytes

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

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

Disk identifier:0x067824c0

Device Boot Start End Blocks Id System

/DEV/SDB1 1 654 5253223+ fd Linux raid AutoDetect

/DEV/SDB2 655 1308 5253255 fd Linux raid AutoDetect

/DEV/SDB3 1309 1962 5253255 FD Linux raid AutoDetect

/DEV/SDB4 1963 15665 110069347+ 5 Extended

/DEV/SDB5 1963 2616 5253223+ FD Linux raid AutoDetect

[Email protected] ~]# mdadm-c/dev/md0-a yes-n 3-x 1-l 5/dev/sdb{1,2,3,5}

mdadm:defaulting to version 1.2 metadata mdadm:array/dev/md0 started.


[Email protected] ~]#watch-n1 cat/proc/mdstat #查看mad的状态

MDADM:SET/DEV/SDB1 Faulty in/dev/md0

Personalities: [RAID6] [RAID5] [RAID4]

Md0:active RAID5 sdb3[4] sdb5[3] sdb2[1] sdb1[0] (F)

10498048 Blocks Super 1.2 level 5, 512k chunk, Algorithm 2 [3/2] [_uu]

[==================> ...] recovery = 91.5% (4804320/5249024) finish=0.1min speed=72603k/sec

Unused devices: <none>

[Email protected] ~]# mkfs.ext4/dev/md0

MKE2FS 1.41.12 (17-may-2010)

Filesystem label=

OS Type:linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

stride=128 blocks, Stripe width=256 blocks

657072 inodes, 2624512 blocks

131225 blocks (5.00%) reserved for the Super user

... The N-line information is omitted here

This filesystem would be automatically checked every mounts or

Whichever comes first. Use Tune2fs-c or-i to override


Step three: Mount to verify that the raid was successfully created


[Email protected] ~]# mkdir/mnt/raid5 #创建挂载点

[Email protected] ~]# mount/dev/md0/mnt/raid5/ #挂载RAID

[Email protected] ~]# mdadm-d/dev/md0

/DEV/MD0:

... The N-line information is omitted here

0 8 0 Active SYNC/DEV/SDB1

1 8 1 Active SYNC/DEV/SDB2

4 8 2 Active SYNC/DEV/SDB3

3 8 21-SPARE/DEV/SDB5

[Email protected] ~]# ls-l/mnt/raid5/

Total 16

drwx------2 root root 16384 03:57 lost+found

[Email protected] ~]# df-lh/mnt/raid5/

Filesystem Size used Avail use% mounted on

/dev/md0 9.8G 23M 9.3G 1%/MNT/RAID5

If you want this file system to mount automatically, you also need to add it to the/etc/fstab

If the simulated RAID5 disk is damaged, the free disk will be automatically replenished to the RIAD5.

    • mdadm-d/dev/md0 View current MD status

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

[Email protected] ~]# mdadm/dev/md0-f/dev/sdb5 #将sdb5设置为faulty (damaged)

MDADM:SET/DEV/SDB5 Faulty in/dev/md0

    • The SDB1 is automatically added to the RAID5, and the following is the status of recovery


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261 /lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

    • After the recovery is complete: Once again, the raid has fully returned to its normal state:


650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "border=" 0 "style=" Background:url ("/e/u261/ Lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

    • At this point, you can remove the broken disk SDB5, re-add the new available partition to do bit RAID5 free disk


[Email protected] ~]# mdadm/dev/md0--remove/dev/sdb5 #从RAID中移除sdb5

Mdadm:hot REMOVED/DEV/SDB5 from/dev/md0

[Email protected] ~]# mdadm/dev/md0--add/dev/sdb6 #将sdb6添加到RIAD中去

Mdadm:added/dev/sdb6

Other commands

-D: explicit RAID details;

Mdadm-d/dev/md#

Management mode:

-F: flag specifies that the disk is damaged;

-A: Adding disks

-R: Remove disk


Observe the status of MD:

Cat/proc/mdstat

To stop the MD device:

Mdadm-s/dev/md#

Watch command:

-N #: Refresh interval, unit is seconds;

watch-n# ' COMMAND '

Linux Learning note raid Introduction, and CENTOS6 on the implementation of soft raid

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.