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

RAID10的搭建:

有两种方法,

第一种:直接使用四块磁盘,创建级别为10的磁盘阵列

第二种:使用四块磁盘先创建两个RAID1,然后在用RAID1创建RAID0

第一步:添加五个磁盘到虚拟机

image

开机后,查看一下

第二步:分别对五个磁盘进行分区,结果如下图:

image

步骤如下:

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

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): +4G #这里我只给了4G,这个大小随意
Partition 1 of type Linux and of size 4 GiB is set

Command (m for help): t  #转换磁盘分区标识类型
Selected partition 1
Hex code (type L to list all codes): fd #指定标识类型为RAID
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: 0x2b819b67

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     8390655     4194304  
fd  Linux raid autodetect

Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

创建一个快照(留作返回,以供第二种方法使用)

image

image

第三步:使用第一种方法创建磁盘阵列RAID10

1、检查磁盘是否已被其他RAID使用

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

image

2、创建RAID10

[root@localhost ~]# mdadm -Cv /dev/md10 -l 10 -n 4 -x 1 /dev/sd[b-f]1

image

3、查看RAID状态信息

[root@localhost ~]#cat /proc/mdstat

[root@localhost ~]#mdadm –E /dev/md10

image

可以看出  sdb1和sdd1组成raid1,sdc1和sde1组成raid1,sdf1为热备盘

4、保存RAID配置信息

mdadm –Dvs #查看配置信息

madmd –Dvs >> /etc/mdadm.conf #保存配置信息到配置文件

image

5、格式化分区,并挂载

mkfs.xfs /dev/md10 #将md10格式化为xfs文件系统

mount /dev/md10 /disk #将磁盘挂载

df –h | tail –1 #检查磁盘大小和挂载状态

4个4G的磁盘组成10阵列,大小应该是4*4G*50%=8G

image

6、设置开机自动挂载

echo “/dev/md10 /disk xfs defaults 0 0” >> /etc/fstab #设置开机自动挂载

tail –1 !$  #检查设置

umount /disk  #卸载磁盘,模拟关机

mount –av  #挂载,模拟开机,并查看挂载信息

image

第四步:快照返回,并使用第二种方法创建RAID10

1、恢复快照

2、创建两个RAID1

3、使用RAID1创建RAID0

4、格式化并挂载

方法见第三步!

5、设置开机自动挂载

方法见第三步!

详情如下:

[root@localhost ~]# mdadm -E /dev/sd[b-f]1 #检查磁盘是否被其他raid占用
mdadm: No md superblock detected on /dev/sdb1.
mdadm: No md superblock detected on /dev/sdc1.
mdadm: No md superblock detected on /dev/sdd1.
mdadm: No md superblock detected on /dev/sde1.
mdadm: No md superblock detected on /dev/sdf1.
[root@localhost ~]# mdadm -Cv /dev/md11 -l 1 -n 2 /dev/sd[b-c]1   #创建第一个raid1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 4190208K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md11 started.
[root@localhost ~]# mdadm -Cv /dev/md12 -l 1 -n 2 /dev/sd[d-e]1  #创建第二个raid1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 4190208K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md12 started.
[root@localhost ~]# mdadm -Cv /dev/md10 -l 0 -n 2 /dev/md11 /dev/md12 #使用raid1 创建RAID0
mdadm: chunk size defaults to 512K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md10 started.
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] [raid0]   #可以看出,md10就是raid10阵列
md10 : active raid0 md12[1] md11[0]
      8376320 blocks super 1.2 512k chunks
     
md12 : active raid1 sde1[1] sdd1[0]
      4190208 blocks super 1.2 [2/2] [UU]
     
md11 : active raid1 sdc1[1] sdb1[0]
      4190208 blocks super 1.2 [2/2] [UU]

     
unused devices: <none>
[root@localhost ~]# mdadm -D /dev/md10
/dev/md10:
        Version : 1.2
  Creation Time : Sun Aug 21 09:58:28 2016
     Raid Level : raid0
     Array Size : 8376320 (7.99 GiB 8.58 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 09:58:28 2016
          State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 512K

           Name : localhost.localdomain:10  (local to host localhost.localdomain)
           UUID : 1fb05d6a:1ca9303a:31aed030:464e978b
         Events : 0

    Number   Major   Minor   RaidDevice State
       0       9       11        0      active sync   /dev/md11
       1       9       12        1      active sync   /dev/md12

[root@localhost ~]# mdadm -D /dev/md11
/dev/md11:
        Version : 1.2
  Creation Time : Sun Aug 21 09:57:02 2016
     Raid Level : raid1
     Array Size : 4190208 (4.00 GiB 4.29 GB)
  Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 09:58:30 2016
          State : active
Active Devices : 2
Working Devices : 2
Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:11  (local to host localhost.localdomain)
           UUID : 1c1c0749:e0b4153a:355a422d:27a889cd
         Events : 18

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

[root@localhost ~]# mdadm -D /dev/md12
/dev/md12:
        Version : 1.2
  Creation Time : Sun Aug 21 09:57:25 2016
     Raid Level : raid1
     Array Size : 4190208 (4.00 GiB 4.29 GB)
  Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Sun Aug 21 09:58:51 2016
          State : active
Active Devices : 2
Working Devices : 2
Failed Devices : 0
  Spare Devices : 0

           Name : localhost.localdomain:12  (local to host localhost.localdomain)
           UUID : df176655:f9735e6a:79e4b2c8:25fa8df9
         Events : 18

    Number   Major   Minor   RaidDevice State
       0       8       49        0      active sync   /dev/sdd1
       1       8       65        1      active sync   /dev/sde1

[root@localhost ~]# mdadm -Dvs >> /etc/mdadm.conf #生成配置信息,一般只要有调整就要修改一下配置信息

posted @ 2016-08-21 10:49  小甘丶  阅读(1627)  评论(0编辑  收藏  举报