大纲:

1.1-1-企业级RAID磁盘阵列

RAID磁盘阵列的原理

RAID0,1,5,10的搭建

硬件RAID卡

1.2-1-使用廉价的磁盘搭建RAID磁盘阵列

实战-配置RAID0带区卷

========================================

1.1 企业级RAID磁盘阵列

RAID磁盘阵列的原理:

RAID(Redundant Array of Independent Disks)独立磁盘冗余阵列

可以提供较普通磁盘更高的速度、安全性,所以服务器在安装时,都会选择创建RAID

RAID有两种创建方式:第一种-->软RAID(通过操作系统软件实现);第二种--->硬RAID(通过硬件阵列卡实现)。

在企业中使用最多的是:raid1、raid10和raid5。不过随着云的高速发展,供应商一般可以把硬件问题解决掉。

RAID磁盘阵列的分类:

raid 阵列有7个基本的级别:0-6,最常用的是0、1、5

不同raid级别的作用、性能、成本是不同的

==========================================

RAID磁盘阵列的工作原理:

raid 0:条带(strping)

需要两块或以上磁盘(最好大小相同)

原理:将数据分段后,分别传输到两块磁盘中。

提高的写入和读取的速度

(即搬运工,原来一个人搬,现在多了一个人,所以速度成倍增加)。

但是由此,每一个磁盘的数据都是很重要的,不能损坏。

特点:成本低、提高整个磁盘性能和吞吐量,即速度快

缺点:没有冗余或错误修复能力

磁盘利用率:100%

任何一个磁盘的损坏将损坏全部数据(分别存储,均分)

==========================================

RAID 1: mirroring(镜像卷)

需要两块及以上磁盘,当两块磁盘大小不一样时,RAID磁盘阵列大小已最小的计算

原理:把一个磁盘中的数据镜像到另一个磁盘(即同步)。

两个磁盘中的内容是完全一致的。

我们还可以准备一个热备盘,当其中一个磁盘短暂暂停工作时,

可以让热备盘顶替使用。在恢复工作后,自动恢复。

特点:有容错能力

缺点:速度慢、占用率低

磁盘利用率:50%

2块100G磁盘组成RAID1,实际使用容量还是100G,而且两块磁盘中数据是相同的

==========================================

RAID 5:

需要三块或以上磁盘

原理:每次存储数据时,数据被平均分配到n-1个磁盘中,随机选中一个磁盘生成校验码。当有一个磁盘坏掉时,还可使用其他磁盘,将这个磁盘中的数据恢复。但若有两个磁盘损坏时,数据将全部损坏。

可以提供热背叛实现故障修复;只损坏一块,没有问题,但是损坏两份,则数据全部损坏

空间利用率:n-1/n

每次存储,随意的会有一个盘存储校验码,校验码为异或运算结果

奇偶校验信息的作用:

当RAID5的一个磁盘数据发生损坏后,利用剩下的数据和相应的奇偶校验信息去恢复被损坏的数据。

扩展异或运算:相对简单的异或运算(相同为0,相异为1)

A

B

Xor

0

0

0

1

0

1

0

1

1

1

1

0

==========================================

RAID 10:镜像+条带(组合)

原理:将RAID1与RAID0 组合在一起使用,

 

RAID 0+1的特点:特别适用于既有大量数据需要存取,同时又对数据安全性要求严格的领域。例如:银行、金融、商业超市、仓库库房、各种档案管理等。

创建步骤:应先创建RAID1,然后使用创建的RAID1设备创建RAID0

==========================================

硬件RAID卡

RAID卡可以分为硬RAID卡和软RAID卡两种。

硬RAID卡:通过硬件来实现RAID功能的就是硬RAID,独立的RAID卡。

主板集成的RAID芯片都是硬RAID。

软RAID卡:通过软件并使用CPU的RAID卡(指使用CPU来完成RAID的常用计算)

软RAID占用CPU资源较高,绝大部分服务器设备是硬件RAID。

Adaptec SATA RAID 2410SA

亚当普特克 ¥550

亚当普特克RAID卡

RAID功能:RAID0、1、5、10、JBOD

接口:Serial ATA

数据传输率:1.5Gb/s 普通硬盘速率:6G

通道数:4

最多连接设备:4

==========================================

管理软raid工具---mdadm

在Linux系统中,我们使用mdadm命令,来管理软RAID

参数

######################

###  mdadm --help  ###

######################

mdadm is used for building, managing, and monitoring

Linux md devices (aka RAID arrays)

Usage: mdadm --create device options...  #创建一个磁盘阵列 –C

            Create a new array from unused devices.

       mdadm --assemble device options...  #激活一个磁盘阵列 –A

            Assemble a previously created array.

       mdadm --build device options...   #创建一个没有metadata的磁盘阵列,很少用

            Create or assemble an array without metadata.

       mdadm --manage device options...  #对已存在的磁盘阵列进行修改

            make changes to an existing array.

       mdadm --misc options... devices  # 报告或修改相关设备

            report on or modify various md related devices.

       mdadm --grow options device  #更新修改的磁盘阵列

            resize/reshape an active array

       mdadm --incremental device  #从一个阵列中添加或移除一个设备(插拔)

            add/remove a device to/from an array as appropriate

       mdadm --monitor options...  #监控重大变化的一个或多个数组。

            Monitor one or more array for significant changes.

       mdadm device options...

            Shorthand for --manage.  #管理阵列使用--manage选项

Any parameter that does not start with '-' is treated as a device name

or, for --examine-bitmap, a file name.

The first such name is often the name of an md device.  Subsequent

names are often names of component devices.

For detailed help on the above major modes use --help after the mode

e.g.

         mdadm --assemble --help

For general help on options use

         mdadm --help-options

##############################

###  mdadm --help-options  ###

##############################

Any parameter that does not start with '-' is treated as a device name

or, for --examine-bitmap, a file name.

The first such name is often the name of an md device.  Subsequent

names are often names of component devices.

Some common options are:

  --help        -h   : General help message or, after above option,

                       mode specific help message

  --help-options     : This help message

  --version     -V   : Print version information for mdadm #版本信息

  --verbose     -v   : Be more verbose about what is happening  #过程信息

  --quiet       -q   : Don't print un-necessary messages #不打印不需要的信息

  --brief       -b   : Be less verbose, more brief #显示简短的过程信息

  --export      -Y   : With --detail, --detail-platform or --examine use

                       key=value format for easy import into environment #

  --force       -f   : Override normal checks and be more forceful #强制执行

  --assemble    -A   : Assemble an array #激活磁盘阵列

  --build       -B   : Build an array without metadata

  --create      -C   : Create a new array

  --detail      -D   : Display details of an array #打印阵列设备详细信息

  --examine     -E   : Examine superblock on an array component ##检测设备块是否在一个阵列数组中

  --examine-bitmap -X: Display the detail of a bitmap file #

  --examine-badblocks: Display list of known bad blocks on device #

  --monitor     -F   : monitor (follow) some arrays #监控

  --grow        -G   : resize/ reshape and array #

  --incremental -I   : add/remove a single device to/from an array as appropriate

  --query       -Q   : Display general information about how a

                       device relates to the md driver

  --auto-detect      : Start arrays auto-detected by the kernel

热备份盘(hot spare or hot standby driver):为了加强容错的功能以及使系统在磁盘故障的情况下能迅速的重建数据,以维持系统的性能,一般的磁盘阵列系统都可使用热备份功能。

Chunk(块): raid存储数据时每个数据段的大小。 4K,64K

chunk(块):每个数据段大小。以K为单位

=============================================================

实战:搭建RAID0磁盘阵列

第一步:添加两块硬盘,并检查

[root@localhost ~]# ls /dev/sd*

/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdc

第二步:分别对两块磁盘进行分区操作,并检查

使用以下方法,分别对/dev/sdb、/dev/sdc进行分区操作

[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x630e77d6.

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): #默认

Using default response p

Partition number (1-4, default 1): #默认

First sector (2048-41943039, default 2048): #默认

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): #默认

Using default value 41943039

Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 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 label type: dos

Disk identifier: 0x630e77d6

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048    41943039    20970496   83  Linux

Command (m for help): l

0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris       

1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-

2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-

3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-

4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx        

5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data   

6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .

7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility  

8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt        

9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access    

a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O       

b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor     

c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs       

e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT           

f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/

10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b

11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor     

12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor     

14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary 

16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS   

17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep       

1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT           

1e  Hidden W95 FAT1 80  Old Minix     

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): fd

Changed type of partition 'Linux' to 'Linux raid autodetect'

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 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 label type: dos

Disk identifier: 0x630e77d6

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048    41943039    20970496   fd  Linux raid autodetect

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]# mdadm -E /dev/sd[b-c] #检查sdb 和 sdc状态

/dev/sdb:

   MBR Magic : aa55

Partition[0] :     41940992 sectors at         2048 (type fd)

/dev/sdc:

   MBR Magic : aa55

Partition[0] :     41940992 sectors at         2048 (type fd)

[root@localhost ~]# mdadm -E /dev/sd[b-c]1 #检查sdb1和sdc1状态

mdadm: No md superblock detected on /dev/sdb1.

mdadm: No md superblock detected on /dev/sdc1.

[root@localhost ~]#

第三步:使用mdadm命令,创建RAID0磁盘阵列,并检查

[root@localhost ~]# mdadm -C -v /dev/md1 -l 0 -n 2 /dev/sd[b-c]1

mdadm: chunk size defaults to 512K

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md1 started.

检查:

[root@localhost ~]# mdadm -E /dev/sd[b-c]

/dev/sdb:

   MBR Magic : aa55

Partition[0] :     41940992 sectors at         2048 (type fd)

/dev/sdc:

   MBR Magic : aa55

Partition[0] :     41940992 sectors at         2048 (type fd)

[root@localhost ~]# mdadm -E /dev/sd[b-c]1

/dev/sdb1:

          Magic : a92b4efc

        Version : 1.2

    Feature Map : 0x0

     Array UUID : b7ca701c:f851d48b:c04edb48:5e427145

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

  Creation Time : Thu Aug 18 21:57:07 2016

   Raid Level : raid0

Raid Devices : 2

Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)

    Data Offset : 32768 sectors

   Super Offset : 8 sectors

   Unused Space : before=32680 sectors, after=0 sectors

          State : clean

    Device UUID : 8239d484:1a906768:b758cc5b:aaacda58

    Update Time : Thu Aug 18 21:57:07 2016

  Bad Block Log : 512 entries available at offset 72 sectors

       Checksum : 45d25591 - correct

         Events : 0

Chunk Size : 512K

Device Role : Active device 0

   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

/dev/sdc1:

          Magic : a92b4efc

    Version : 1.2

    Feature Map : 0x0

     Array UUID : b7ca701c:f851d48b:c04edb48:5e427145

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

  Creation Time : Thu Aug 18 21:57:07 2016

     Raid Level : raid0

   Raid Devices : 2

Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)

    Data Offset : 32768 sectors

   Super Offset : 8 sectors

   Unused Space : before=32680 sectors, after=0 sectors

          State : clean

  Device UUID : a4adb898:e645b661:175ed13a:9ca57053

    Update Time : Thu Aug 18 21:57:07 2016

  Bad Block Log : 512 entries available at offset 72 sectors

       Checksum : 2ca07dd2 - correct

         Events : 0

     Chunk Size : 512K

Device Role : Active device 1

   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

[root@localhost ~]# mdadm -D /dev/md1

/dev/md1:

    Version : 1.2

  Creation Time : Thu Aug 18 21:57:07 2016

     Raid Level : raid0

     Array Size : 41908224 (39.97 GiB 42.91 GB)

   Raid Devices : 2

  Total Devices : 2

    Persistence : Superblock is persistent

    Update Time : Thu Aug 18 21:57:07 2016

          State : clean

Active Devices : 2

Working Devices : 2

Failed Devices : 0

  Spare Devices : 0

     Chunk Size : 512K

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

           UUID : b7ca701c:f851d48b:c04edb48:5e427145

         Events : 0

    Number   Major   Minor   RaidDevice State

       0       8       17        0      active sync   /dev/sdb1

       1       8       33        1      active sync   /dev/sdc1

[root@localhost ~]# mdadm -E /dev/md1

mdadm: No md superblock detected on /dev/md1.

第四步:创建文件系统

[root@localhost ~]# mkfs.ext4 /dev/md1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=128 blocks, Stripe width=256 blocks

2621440 inodes, 10477056 blocks

523852 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2157969408

320 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624

Allocating group tables: done                           

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done  

[root@localhost ~]#

第五步:挂载,并设置开机自动挂载

[root@localhost ~]# mkdir /disk

[root@localhost ~]# mount /dev/md1 /disk

[root@localhost ~]# df | tail -1

/dev/md1               41118944   49176  38957976   1% /disk

[root@localhost ~]#

设置开机自动挂载:

[root@localhost ~]# blkid /dev/md1

/dev/md1: UUID="7b702168-4653-43cb-8fb0-6c692a6ff8df" TYPE="ext4"

[root@localhost ~]# vim /etc/fstab

[root@localhost ~]# df | tail -1

/dev/md1               41118944   49176  38957976   1% /disk

[root@localhost ~]# umount /disk

[root@localhost ~]# mount -a

[root@localhost ~]# df | tail -1

/dev/md1               41118944   49176  38957976   1% /disk

[root@localhost ~]#

第六步:模拟一块磁盘损坏

取消开机自动挂载后,直接卸载掉一块磁盘,重启即可。因为RAID0不具备容错能力,当有一个磁盘损坏时,磁盘阵列自然失败!!!

cat !$  # !$-->上一条命令的最后一个参数

watch cat /proc/mdstat #支持查看这条命令的执行结果

cat /proc/mdstat  #查看当前磁盘阵列状态

1-15-1 RAID磁盘阵列的原理和搭建的更多相关文章

  1. 学习笔记:CentOS7学习之十五: RAID磁盘阵列的原理与搭建

    目录 学习笔记:CentOS7学习之十五: RAID磁盘阵列的原理与搭建 14.1 RAID概念 14.1.1 RAID几种常见的类型 14.1.2 RAID-0工作原理 14.1.3 RAID-1工 ...

  2. Linux下RAID磁盘阵列的原理与搭建

    RAID概念 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有"独立磁盘构成的具有冗余能力的阵列"之意. 磁盘阵列是由很多价格较 ...

  3. RAID磁盘阵列的原理与搭建

    学习导图 RAID-0结构关系图 RAID-1结构关系图 RAID-5:条带+分布校验(三块磁盘以上) RAID-10:镜像+条带(四块磁盘以上) RAID-0 添加两块硬盘,分别为磁盘1.磁盘2.最 ...

  4. RAID磁盘阵列的原理

    RAID概念 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意.磁盘阵列是由很多价格较便宜的磁盘,以硬件(R ...

  5. 快速理解几种常用的RAID磁盘阵列级别

    我发现周围不少人在学习和理解RAID磁盘阵列的原理时,找了很多专业的资料来看,但是因为动手的机会比较少,因此看完以后还是似懂非懂,真正遇到实际的方案设计的时候,还是拿不定主意. 因此,我结合自己在过去 ...

  6. 末学者笔记--Linux中RAID磁盘阵列及centos7启动过程

    <一>RAID概念 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意. 磁盘阵列是由很多价格较便 ...

  7. RAID磁盘阵列结构

    RAID磁盘阵列结构原理其实很简单,就是每块硬盘不插在主板的硬盘接口上了,而是全插在RAID卡上,然后RAID卡再插到主板上,由RAID卡统一管理硬盘,做各种RAID磁盘策略(RAID0,RAID1, ...

  8. Linux进阶之RAID磁盘阵列、系统启动及dd命令

    本节内容 1.      磁盘阵列 RAID0: 条带卷 2+ 100% 读写速度快,不容错 RAID1: 镜像卷 2   50% 读写速度慢,容错 RAID5: 奇偶校验条带卷 3 读写速度快,容错 ...

  9. RAID磁盘阵列及CentOS7系统启动流程

    磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意,,数据读取无影响.将数据切割成许多区段,分别存放在各个硬盘 ...

随机推荐

  1. Git的安装和设置

    1.客户端下载 首先可以在https://git-scm.com/downloads下载客户端,进行安装. 2.安装 安装比较简单,可以直接默认一步一步往下安装即可: 3.配置github的ssh秘钥 ...

  2. git pull和git merge区别&&Git冲突:commit your changes or stash them before you can merge. 解决办法

    http://blog.csdn.net/sidely/article/details/40143441 原文: http://www.tech126.com/git-fetch-pull/ Git中 ...

  3. gitHub新项目的上传

    github作为一个开源托管平台,除了有机会学习各位大神的开源项目,还能托管自己写的一些小Demo,作为github新进菜鸟,今天就整理下上传Demo所需的命令和操作步骤,防止我这谜一样的记忆力. 1 ...

  4. 一个简单的ssm项目

    准备说明jdk.tomcat.idea.mave配置请看我前两篇,这里说下mysql以及我的mysql图像化工具 数据库 项目概览 项目构建--------搭建一个简单的mave的web项目,构建步骤 ...

  5. windows平台kettle连接hbase的问题

    我本机安装的环境是centos7,并在本机上安装了zookeeper,hadoop,hbase,hive等组件, 使用pdi7.1来连接hbase,把mysql表中的数据导出到hbase中去,没有问题 ...

  6. iOS 绘制一个表盘时钟,秒针效果可以“扫秒/游走”

    最近自己 也尝试写了一个表盘时钟,初衷源于等车时候一个老奶奶问时间,我打开手机,时间数字对我来说相对敏感,但是老奶奶是看不清的,我想识别 还是看表盘 老远 看时针分针角度就可以识别当前时间. 于是我想 ...

  7. TOSCA自动化测试工具--Convert to Template

    转换成用例模板

  8. 关于TOSCA自动化测试工具, 我想问一些问题(持续整理中)

    通过学习,实践踩坑,有以下问题不太明白 1.  Artifacts and results from your complete test portfolio (cross-browser, mobi ...

  9. $Python常用内置函数典型用法

    Python中有许多功能丰富的内置函数,本文基于Python 2.7,就常用的一些函数的典型用法做一些积累,不断更新中. sorted函数的三种用法 # coding:utf-8 # sorted函数 ...

  10. C#基础--多线程

    一.微软早期操作系统中的问题 在早期的操作系统中,应用程序都是在同一个地址空间中运行的,每个程序的数据其它程序都是可见的,并且因为早期CPU是单内核 的所以所有的执行都是线性的.这就引出两个问题: 第 ...