Linux disk arrays in raid

A. RAID (Redundant Arrays of Independent Disks, RAID) "Outside disk array configuration with redundancy" means.

   Disk array is much less expensive disk, a combination of hardware (RAID cards) or software (mdadm) to form a huge capacity of the disk group, together with a plurality of disks, the entire disk to enhance system performance. Using this technique, the data is cut into a number of sections, each stored on each hard disk. The disk array also uses parity check (Parity Check) concept, a hard disk when any failure in the array, the read data is still in the data.
Note: RAID can prevent data loss, but it does not completely guarantee that your data will not be lost, so the use of RAID while still pay attention to back up important data.

Two ways to create .RAID

    There are two ways to create a RAID: RAID software (implemented by the operating system software) and hardware RAID (using hardware array card); understand raid1, raid5 and raid10. But with the rapid development of cloud vendor hardware problems can generally be resolved.

Three .RAID disk array features

High-speed disk access (speed): a hard drives ordinary RAID disk array, the write data in the host, the host to the RAID controller data to be written into a plurality of blocks of data, and then written to disk in parallel arrays; Host Read data fetch, RAID controller reads data in parallel on each dispersed in the hard disk array, to reassemble them back to the host. Since a parallel read and write operations, thereby improving the access speed of the storage system. 
Expansion. 
Data redundancy

Four types .RAID

raid级别:raid 0 raid 1 raid5 raide 10 raid 01

 

RAID 0

0: (stripe) banding pattern, at least two hard drives, one per data into a plurality of parts stored in a plurality of disks, and are in a horizontal strip

Advantages : read and write speed, with the number of blocks is the number of times the disk  disadvantages : no redundancy (also known as fault tolerance)  space utilization : the sum of a plurality of disks 100%

RAID 1

1: (mirror) image mode, the number of disks required multiple of two, two identical data stored on the disk, when a disk fails, the data can still be read

Advantages: redundancy

Disadvantages: only 50% disk utilization, write rate of decline

RAID 5

5: check code check code pattern, at least three disks, each time data is stored, using the band pattern memory  storing the n-1 number of disks, the disk is stored in a further data to several other disks encrypted data obtained after an encryption method, and each storage disk stores the encrypted data is constantly changing, when a disc wherein data is any damage, can come to rest by two disks and encryption data another known data disk having a high redundancy

Advantages : read and write speed, there is redundancy

Disadvantage : disk utilization is n-1 / n, when two disk failures, data will be lost

Combined with RAID10

10: mirror + stripe pattern, at least four fast hard drive, hard disks Raid1 first two, then combines the two into a Raid1 Raid0, when storing a data points, each data storage Raid1 combinations are divided equally, then again mirror the combination patterns stored Raid1

Advantages : read and write speed, high redundancy 

Drawback : the disk utilization of 50%

 

 

Combined with RAID01

RAID01 do first striped mirror for further, essentially mirroring physical disk to achieve

Advantages: read and write speed, high redundancy 

Disadvantages: disk utilization was 50%, worse than the 10 security

Compare:

 

 

RAID10 and RAID01 comparison of

    两者最重要的区别在于:RAID10的底层是镜像RAID1,而镜像就保证了当有一块硬盘比如A1损坏时,并不影响他的写功能,读性能可能稍微有所降低(大概降低1/8)。但是RAID01的底层是条带RAID0,而条带就导致了只要有一块硬盘比如左边的Disk0中的A1损坏时,那么整个左边的RAID0就不能使用了,所以整个RAID01就变成了只有右边的RAID0可以使用了,也就是从RAID01变成了RAID0,读性能马上降低一般,写性能没有影响,可靠性变得最差。仅仅凭借这一点,我们就绝不应该使用RAID01,而应该选择RAID10

 

五.RAID命令

    命令:mdadm (需要下载)
    #功能:创建/管理/删除 磁盘阵列
    #语法格式:
    mdadm [模式] <磁盘阵列名称> [选项] <组成设备>
    #模式:

  assemble:将以前定义的某个阵列加入当前在用阵列。
  create:创建一个新的阵列,每个设备具有超级块
  manage: 管理阵列,比如增加或移除
  misc:允许单独对阵列中的某个设备做操作,比如抹去超级块或 终止在用的阵列。
  follow or Monitor:监控磁盘阵列的状态
  grow:改变磁盘阵列容量或阵列中的设备数目

  

    选项:
 

 -A:加入一个以前定义的阵列
 -C:创建一个新的阵列 (重要)
 -D:打印一个或多个设备的详细信息
 -E:打印设备上的超级块的内容
 -h:帮助信息,用在以上选项后,则显示该选项信息
 -v:显示细节
 -b:较少的细节。用于-D和-E选项
 -f, --force 强制执行
 -c:指定配置文件,缺省为 /etc/mdadm.conf
 -s:扫描配置文件或 /proc/mdstat以搜寻丢失的信息。

  

    create 或 build 使用的选项:

 -c:指定块大小,单位 kb. 缺省为 64.
 -l,:设定RAID模式.(非常重要)
 -n=:指定阵列中可用设备数目。
 -x :指定初始阵列的热备盘数目。
 -a, --auto{=no,yes,md,mdp,part,p}{NN} :创建RAID同时是否创建设备。

  

例:使用sdb sdc 创建raid0
mdadm -C /dev/md0 -l 0 -n 2 /dev/sd{b,c}1
raid查看方法

cat /proc/mdstat       mdadm --detail /dev/mdXXX

  

删除raid (删除raid前需要卸载对应的挂载点)

mdadm --stop /dev/mdXXXX

  

 

Guess you like

Origin www.cnblogs.com/t-ym/p/11617094.html