大纲:

1、创建RAID1

2、创建RAID5

3、创建RAID10

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

1、创建RAID1

RAID1原理:需要两块或以上磁盘,可添加热备盘。

在写入数据时,会在另一块磁盘中生成该文件的镜像(即同步)。

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

故当一块磁盘损坏时,可使用另一块镜像盘中的数据。(当拥有热备盘时,若镜像盘损坏,可由热备盘替代)

磁盘利用率为50%,即两块100G的磁盘构成RAID1只能提供100G的可用空间。

实战:创建RAID1

第一步:给虚拟机添加三块硬盘,并开机检查。

[root@localhost ~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdc  /dev/sdd
[root@localhost ~]#

效果如图:

第二步:分别对三块磁盘分区,并修改其标签

使用相同办法,分别对/dev/sdb、/dev/sdc、/dev/sdd进行分区

[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 0xeed790f7.

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): 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: 0xeed790f7

   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 ~]#

效果如图:

第三步:创建RAID1磁盘阵列

检查三块磁盘是否被其他磁盘阵列使用

mdadm –E /dev/sd[b-d]1

使用分区后的三块磁盘,创建RAID1磁盘阵列

(其中-n指定两块设备,-x指定一个热备盘,-l 指定级别为RAID1 -C创建 -v显示信息 /dev/md1—>指定创建的设备名)

mdadm -Cv /dev/md1 -l 1 -n 2 -x 1 /dev/sd[b-d]1

检查:

[root@localhost ~]# ls /dev/md1
/dev/md1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
     Array Size : 20954112 (19.98 GiB 21.46 GB)
  Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 01:28:01 2016
          State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
  Spare Devices : 1

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1

       2       8       49        -      spare   /dev/sdd1
[root@localhost ~]# mdadm -E /dev/md1
mdadm: No md superblock detected on /dev/md1.
[root@localhost ~]# mdadm -E /dev/sd[b-d]1
/dev/sdb1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
           Name : localhost.localdomain:1  (local to host localhost.localdomain)
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
   Raid Devices : 2

Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)
     Array Size : 20954112 (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 : 483270f1:90ae6527:ab2ceee6:58ee030d

    Update Time : Sun Aug 21 01:28:01 2016
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : 5e434c0e - correct
         Events : 17

   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 : 9f8c8a03:8036f47c:788bd593:8c0c83cd
           Name : localhost.localdomain:1  (local to host localhost.localdomain)
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
   Raid Devices : 2

Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)
     Array Size : 20954112 (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 : b6a96682:0ca07895:8fafe1f0:c5761864

    Update Time : Sun Aug 21 01:28:01 2016
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : be54c04a - correct
         Events : 17

   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
/dev/sdd1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
           Name : localhost.localdomain:1  (local to host localhost.localdomain)
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
   Raid Devices : 2

Avail Dev Size : 41908224 (19.98 GiB 21.46 GB)
     Array Size : 20954112 (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 : 9ee8a186:310bc49c:66788d58:ec4b1d9a

    Update Time : Sun Aug 21 01:28:01 2016
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : 678c0856 - correct
         Events : 17

   Device Role : spare
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
[root@localhost ~]#

查看磁盘阵列状态信息:

生成配置信息:

[root@localhost ~]# mdadm -Dvs >> /etc/mdadm.conf
[root@localhost ~]# cat !$     # !$  --> 上一条命令最后一个参数

第四步:格式化并挂载

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

效果如图:

[root@localhost ~]# mkdir /disk

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

[root@localhost ~]# df –h | tail –1

效果如图:

第五步:设置开机启动

[root@localhost ~]# echo "/dev/md1 /disk xfs defaults 0 0 " >> /etc/fstab
[root@localhost ~]# cat !$

[root@localhost ~]# df | grep /disk
[root@localhost ~]# umount /disk
[root@localhost ~]# mount –a  #测试,umount /disk 模拟重启,mount –a 模拟开机
[root@localhost ~]# df | tail –1 #检查挂载结果

效果如图:

注:也可使用   mount –av   查看挂载信息

 

第六步:RAID1磁盘故障模拟及修复

模拟RAID磁盘故障:

[root@localhost ~]# mdadm -D /dev/md1 #查看/dev/md1状态
/dev/md1:
        Version : 1.2
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
     Array Size : 20954112 (19.98 GiB 21.46 GB)
  Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 01:43:47 2016
          State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
  Spare Devices : 1

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1

       2       8       49        -      spare   /dev/sdd1
[root@localhost ~]# mdadm /dev/md1 -f /dev/sdb1   #设置/dev/sdb1损坏
mdadm: set /dev/sdb1 faulty in /dev/md1
[root@localhost ~]# mdadm -D /dev/md1 #查看/dev/md1状态
/dev/md1:
        Version : 1.2
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
     Array Size : 20954112 (19.98 GiB 21.46 GB)
  Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 01:44:50 2016
          State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 1
  Spare Devices : 1

Rebuild Status : 3% complete

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
         Events : 19

    Number   Major   Minor   RaidDevice State
       2       8       49        0      spare rebuilding   /dev/sdd1
       1       8       33        1      active sync   /dev/sdc1

       0       8       17        -      faulty   /dev/sdb1
[root@localhost ~]#

模拟RAID磁盘故障:

1、停用RAID1磁盘阵列

2、清除/dev/sdb1超级块标识

3、激活RAID1磁盘阵列

4、添加/dev/sdb1到磁盘阵列中

详情如下:

[root@localhost ~]# mdadm /dev/md1 --zero-superblock /dev/sdb1 
mdadm: No action given for /dev/md1 in --misc mode
       Action options must come before device names
[root@localhost ~]# mdadm --zero-superblock /dev/sdb1 #磁盘阵列挂载并且激活状态下,去除标志是不会成功的
mdadm: Couldn't open /dev/sdb1 for write - not zeroing
[root@localhost ~]# mdadm -S /dev/md1   #停用RAID1磁盘阵列
mdadm: Cannot get exclusive access to /dev/md1:Perhaps a running process, mounted filesystem or active volume group?
[root@localhost ~]# df |grep disk
/dev/md1               20943872   32932  20910940   1% /disk
[root@localhost ~]# umount /disk
[root@localhost ~]# mdadm -S /dev/md1  #停用RAID1磁盘阵列
mdadm: stopped /dev/md1
[root@localhost ~]# mdadm --zero-superblock /dev/sdb1  #清除/dev/sdb1超级块标识
[root@localhost ~]# mdadm -As /dev/md1      #激活RAID1磁盘阵列
mdadm: /dev/md1 has been started with 2 drives.
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
     Array Size : 20954112 (19.98 GiB 21.46 GB)
  Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 01:49:16 2016
          State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
         Events : 36

    Number   Major   Minor   RaidDevice State
       2       8       49        0      active sync   /dev/sdd1
       1       8       33        1      active sync   /dev/sdc1


[root@localhost ~]# mdadm /dev/md1 -a /dev/sdb1 #添加/dev/sdb1到磁盘阵列中
mdadm: added /dev/sdb1
[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Sun Aug 21 01:26:17 2016
     Raid Level : raid1
     Array Size : 20954112 (19.98 GiB 21.46 GB)
  Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 01:50:15 2016
          State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
  Spare Devices : 1

           Name : localhost.localdomain:1  (local to host localhost.localdomain)
           UUID : 9f8c8a03:8036f47c:788bd593:8c0c83cd
         Events : 37

    Number   Major   Minor   RaidDevice State
       2       8       49        0      active sync   /dev/sdd1
       1       8       33        1      active sync   /dev/sdc1

       3       8       17        -      spare   /dev/sdb1


[root@localhost ~]# mdadm -Dvs >> /etc/mdadm.conf  #重新生成配置信息,在磁盘阵列信息发生改变后,要重新生成配置信息
[root@localhost ~]# cat !$
cat /etc/mdadm.conf
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 spares=1 name=localhost.localdomain:1 UUID=9f8c8a03:8036f47c:788bd593:8c0c83cd
   devices=/dev/sdb1,/dev/sdc1,/dev/sdd1
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 spares=1 name=localhost.localdomain:1 UUID=9f8c8a03:8036f47c:788bd593:8c0c83cd
   devices=/dev/sdb1,/dev/sdc1,/dev/sdd1
[root@localhost ~]#

1-15-2-RAID1 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)的更多相关文章

  1. 1-15-2-RAID10 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)

    RAID10的搭建: 有两种方法, 第一种:直接使用四块磁盘,创建级别为10的磁盘阵列 第二种:使用四块磁盘先创建两个RAID1,然后在用RAID1创建RAID0 第一步:添加五个磁盘到虚拟机 开机后 ...

  2. 1-15-2-RAID5 企业级RAID磁盘阵列的搭建(RAID1、RAID5、RAID10)

    RAID5的搭建 第一步:添加四个磁盘,开机并检查(略过) 第二步:使用fdisk命令分别对四个磁盘进行分区,效果如下图: 第三步:使用mdadm命令创建RAID5磁盘阵列 [root@localho ...

  3. RAID磁盘阵列的搭建(以raid0、raid1、raid5、raid10为例)

    mdadm工具的使用 -C或--creat 建立一个新阵列 -r 移除设备 -A 激活磁盘阵列 -l 或--level= 设定磁盘阵列的级别 -D或--detail 打印阵列设备的详细信息 -n或-- ...

  4. 1-15-1 RAID磁盘阵列的原理和搭建

    大纲: 1.1-1-企业级RAID磁盘阵列 RAID磁盘阵列的原理 RAID0,1,5,10的搭建 硬件RAID卡 1.2-1-使用廉价的磁盘搭建RAID磁盘阵列 实战-配置RAID0带区卷 ==== ...

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

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

  6. Linux系统的RAID磁盘阵列

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

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

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

  8. RAID磁盘阵列技术

    RAID磁盘阵列技术 1.RAID概述 RAID(Redundant Array of Independent Disk),从字面意思讲的是基于独立磁盘的具有冗余的磁盘阵列,其核心思想是将多块独立磁盘 ...

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

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

随机推荐

  1. PAT 1078 Hashing[一般][二次探查法]

    1078 Hashing (25 分) The task of this problem is simple: insert a sequence of distinct positive integ ...

  2. WSDL(WebService描述语言)文件介绍

    一.WSDL 1.WSDL 文档的组成部分 <portType>:web service 执行的操作 <message>:web service 使用的消息 <types ...

  3. mysql时间戳转换成可读时间格式

    代码: SELECT FROM_UNIXTIME(1234567890, '%Y-%m-%d %H:%i:%S') 附:在mysql中,一个时间字段的存储类型是int(11),怎么转化成字符类型,比方 ...

  4. Foundations of RESTful Architecture

    Introduction The Representational State Transfer (REST) architectural style is not a technology you ...

  5. springer论文模板参考文献的顺序问题

    latex环境 MikTex 2.9 + TeXstudio 2.12.8 (+ Mendeley) 问题 springer提供的latex模板 中最后的参考文献是按照字母顺序排列的.我想要弄成按照文 ...

  6. Python基本知识 os.path.join与split() 函数

    Python中有join和os.path.join()两个函数,具体作用如下: join:连接字符串数组.将字符串.元组.列表中的元素以指定的字符(分隔符)连接生成一个新的字符串os.path.joi ...

  7. CSS Display(显示)和Visibility(可见性)

    CSS Display(显示)和Visibility(可见性) 一.简介 display属性设置一个元素应如何显示(隐藏不占用空间),visibility属性指定一个元素应可见还是隐藏(隐藏占用空间) ...

  8. Java-性能调优-理解GC日志

    [ ~]# cat gc.log.0 | grep 'Full GC' 1.652: [Full GC (System) 1.652: [CMS: 0K->21718K(262144K), 0. ...

  9. 20145327 《Java程序设计》第三周学习总结

    20145327 <Java程序设计>第三周学习总结 教材学习内容总结 对象:存在的具体实体,具有明确的状态和行为. 类:具有相同属性和行为的一组对象的集合,用于组合各个对象所共有操作和属 ...

  10. 实现在vista和win7中使用管理员权限接收WM_DROPFILES(OnDropFiles())消息的方法(好像XP不支持这个函数)

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #pragma once   #ifndef WM_COPYGLOBALD ...