Linux学习作业2-3 创建RAID01磁盘阵列

要求:使用/dev/sdX  四块硬盘,创建RAID-01

 第一步:添加磁盘

Linux学习作业2-3 创建RAID01磁盘阵列

Linux学习作业2-3 创建RAID01磁盘阵列

第二步: 创建RAID01

首先创建底层RAID0:

创建第一组RAID0,命名为/dev/md1,使用磁盘/dev/sd[b-c]:

[[email protected] ~]# mdadm -Cv /dev/md1 -a yes -n2 -l0 /dev/sdb /dev/sdc
mdadm: chunk size defaults to 512K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
[[email protected] ~]# 
创建第二组RAID0,命名为/dev/md2,使用磁盘/dev/sd[d-e]:

[[email protected] ~]# mdadm -Cv /dev/md2 -a yes -n2 -l0 /dev/sdd /dev/sde
mdadm: chunk size defaults to 512K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
[[email protected] ~]# 

再创建上层RAID1:

创建上层RAID1,命名为/dev/md0,使用磁盘/dev/md1、/dev/md2:

[[email protected] ~]# mdadm -Cv /dev/md0 -a yes -n2 -l1 /dev/md1 /dev/md2
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 41877504K
Continue creating array? 
Continue creating array? (y/n) 
Continue creating array? (y/n) y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[[email protected] ~]# 
[[email protected] ~]#

查看创建结果:

上层:

[[email protected] ~]# mdadm -D /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Mar 20 05:04:07 2019
     Raid Level : raid1
     Array Size : 41877504 (39.94 GiB 42.88 GB)
  Used Dev Size : 41877504 (39.94 GiB 42.88 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Mar 20 05:05:25 2019
          State : clean, resyncing 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

  Resync Status : 41% complete

           Name : localhost.localdomain:0  (local to host localhost.localdomain)
           UUID : c32b16b5:5476f441:cb82cfe1:699b1f25
         Events : 6

    Number   Major   Minor   RaidDevice State
       0       9        1        0      active sync   /dev/md1
       1       9        2        1      active sync   /dev/md2
[[email protected] ~]# 
底层:

[[email protected] ~]# mdadm -D /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Wed Mar 20 04:59:33 2019
     Raid Level : raid0
     Array Size : 41910272 (39.97 GiB 42.92 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Mar 20 04:59:33 2019
          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 : 4e45291e:45d07c68:271cff50:c41a643c
         Events : 0

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       32        1      active sync   /dev/sdc
[[email protected] ~]# 
[[email protected] ~]# mdadm -D /dev/md2
/dev/md2:
        Version : 1.2
  Creation Time : Wed Mar 20 05:01:10 2019
     Raid Level : raid0
     Array Size : 41910272 (39.97 GiB 42.92 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Mar 20 05:01:10 2019
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 512K

           Name : localhost.localdomain:2  (local to host localhost.localdomain)
           UUID : 13a095e0:09ed18d1:05fba38d:faa09dd4
         Events : 0

    Number   Major   Minor   RaidDevice State
       0       8       48        0      active sync   /dev/sdd
       1       8       64        1      active sync   /dev/sde
[[email protected] ~]# 

第三步:建立文件系统

[[email protected] ~]# mkfs.xfs /dev/md0
meta-data=/dev/md0               isize=512    agcount=16, agsize=654208 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=10467328, imaxpct=25
         =                       sunit=128    swidth=256 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=5112, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[[email protected] ~]#
[[email protected] ~]# lsblk -f /dev/md0
NAME FSTYPE LABEL UUID                                 MOUNTPOINT
md0  xfs          4e2957bf-ee04-4fe0-8bbc-a562b459874a 
[[email protected] ~]# 

第四步:挂载使用

[[email protected] ~]# mkdir /myraid01
[[email protected] ~]# 
[[email protected] ~]# mount /dev/md0 /myraid01/
[[email protected] ~]#
[[email protected] ~]# df -hT /dev/md0
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/md0       xfs    40G   33M   40G   1% /myraid01
[[email protected] ~]#