41.软RAID搭建与删除-RAID0+RAID1+RAID5+RAID6+RAID10+RAID50

时间:2024-03-04 09:38:53

软RAID搭建

Linux内核中有一个md(multiple devices)模块在底层管理RAID设置,他会在应用层提供一个应用程序的工具mdadm,mdadm是Linux下用于创建和管理软件RAID的命令。

mdadm命令常见参数:

-C--creat

建立一个新阵列

-r

移除设备

-A

激活磁盘阵列

-l --level=

设定磁盘阵列的级别

-D--detail

打印阵列设备的详细信息

-n--raid-devices=

指定阵列成员(分区/磁盘)的数量

-s--scan

扫描配置文件或/proc/mdstat得到阵列缺失信息

-x--spare-devicds=

指定阵列中备用盘的数量

-f

将设备状态定为故障

-c--chunk=

设定阵列的块chunk块大小,单位为KB

-a--add

添加设备到阵列

-G--grow

改变阵列大小或形态

-v

--verbose 显示详细信息

-S

停止阵列

 

磁盘准备,关闭虚拟机,添加磁盘20块:

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

sda   sda2  sdb   sdd   sdf   sdh   sdj   sdl   sdn   sdp   sdr   sdt  

sda1  sda3  sdc   sde   sdg   sdi   sdk   sdm   sdo   sdq   sds   sdu 

RAID0

raid种类

磁盘

热备盘

raid0

sdbsdc

 

 

创建RAID0

[root@localhost dev]# mdadm -C -v /dev/md0 -l 0 -n 2 /dev/sdb /dev/sdc

mdadm: chunk size defaults to 512K

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.

 

查看RAID0阵列信息

[root@localhost dev]# mdadm -Ds

ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 UUID=3e7915c3:206f4f2b:c1b0fc8f:54ea6e37

 

 

[root@localhost dev]# mdadm -D /dev/md0

/dev/md0:

           Version : 1.2

     Creation Time : Mon Dec  7 09:31:13 2020

        Raid Level : raid0

        Array Size : 20953088 (19.98 GiB 21.46 GB)

      Raid Devices : 2

     Total Devices : 2

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 09:31:13 2020

             State : clean

    Active Devices : 2

   Working Devices : 2

    Failed Devices : 0

     Spare Devices : 0

 

        Chunk Size : 512K

 

Consistency Policy : none

 

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

              UUID : 3e7915c3:206f4f2b:c1b0fc8f:54ea6e37

            Events : 0

 

    Number   Major   Minor   RaidDevice State

       0       8       16        0      active sync   /dev/sdb

       1       8       32        1      active sync   /dev/sdc

 

格式化阵列

[root@localhost dev]# mkfs.xfs /dev/md0

meta-data=/dev/md0               isize=512    agcount=16, agsize=327296 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0, sparse=0

data     =                       bsize=4096   blocks=5236736, imaxpct=25

         =                       sunit=128    swidth=256 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=8 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

 

阵列挂载

[root@localhost dev]# mkdir raid_0

[root@localhost dev]# mount /dev/md0 /dev/raid_0/

 

查看是否挂载成功

[root@localhost dev]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        55G  3.9G   51G   8% /

devtmpfs        3.8G     0  3.8G   0% /dev

tmpfs           3.9G     0  3.9G   0% /dev/shm

tmpfs           3.9G   13M  3.8G   1% /run

tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup

/dev/sda1       497M  166M  332M  34% /boot

tmpfs           781M  4.0K  781M   1% /run/user/42

tmpfs           781M   24K  781M   1% /run/user/0

/dev/md0         20G   33M   20G   1% /dev/raid_0

 

阵列开机自动挂载

文件名挂载

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

追加如下内容:

#raid_0_wenjian_guazai

/dev/md0        /dev/raid_0     xfs     defaults        0 0

 

UUID挂载

查看UUID

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

/dev/md0: UUID="f1c3bf57-4dda-4d7c-84e1-39ee319d8759" TYPE="xfs"

 

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

追加如下内容:

#raid_0_UUID_guazai

UUID=f1c3bf57-4dda-4d7c-84e1-39ee319d8759 /dev/raid_0 xfs defaults 0 0

 

RAID1

raid种类

磁盘

热备盘

raid1

sddsde

sdf

raid1+1(raid1加一块热备盘)

对于raid1来说,可以增加成员盘,也可以减少

创建RAID1

[root@localhost dev]#

[root@localhost dev]# mdadm -C -v /dev/md1 -l 1 -n 2 -x 1 /dev/sd[d,e,f]

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 10476544K

Continue creating array? (y/n) y

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md1 started.

 

将RAID1阵列信息保存到/etc/mdadm.conf配置文件中

[root@localhost dev]# mdadm -Dsv > /etc/mdadm.conf

 

查看RAID1阵列信息

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

/dev/md1:

           Version : 1.2

     Creation Time : Mon Dec  7 09:44:00 2020

        Raid Level : raid1

        Array Size : 10476544 (9.99 GiB 10.73 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 2

     Total Devices : 3

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 09:44:17 2020

             State : clean

    Active Devices : 2

   Working Devices : 3

    Failed Devices : 0

     Spare Devices : 1

 

Consistency Policy : resync

 

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

              UUID : 6aa69cf9:255ef882:08b86b9a:679e6c6d

            Events : 17

 

    Number   Major   Minor   RaidDevice State

       0       8       48        0      active sync   /dev/sdd

       1       8       64        1      active sync   /dev/sde

 

       2       8       80        -      spare   /dev/sdf

 

格式化阵列

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

meta-data=/dev/md1               isize=512    agcount=4, agsize=654784 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0, sparse=0

data     =                       bsize=4096   blocks=2619136, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

 

阵列挂载

[root@localhost dev]# mkdir raid1

[root@localhost dev]# mount /dev/md1 /dev/raid1

 

查看阵列是否挂载成功

[root@localhost dev]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        55G  3.9G   51G   8% /

devtmpfs        3.8G     0  3.8G   0% /dev

tmpfs           3.9G     0  3.9G   0% /dev/shm

tmpfs           3.9G   13M  3.8G   1% /run

tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup

/dev/sda1       497M  166M  332M  34% /boot

tmpfs           781M  4.0K  781M   1% /run/user/42

tmpfs           781M   24K  781M   1% /run/user/0

/dev/md0         20G   33M   20G   1% /dev/raid_0

/dev/md1         10G   33M   10G   1% /dev/raid1

 

阵列开机自动挂载

文件名挂载

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

追加如下内容:

#raid_1_wenjian_guazai

/dev/md1        /dev/raid1     xfs     defaults        0 0

 

UUID挂载

查看UUID

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

/dev/md1: UUID="2e4fbf9d-1dfc-4280-bc31-6a71c620508e" TYPE="xfs"

 

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

追加如下内容:

#raid_1_UUID_guazai

UUID=2e4fbf9d-1dfc-4280-bc31-6a71c620508e /dev/raid1 xfs defaults 0 0

 

模拟磁盘损坏

模拟数据盘/dev/sde出现故障,观察热备盘/dev/sdf是否自动顶替故障盘。

 

将磁盘设定为故障

[root@localhost dev]# mdadm /dev/md1 -f /dev/sde

mdadm: set /dev/sde faulty in /dev/md1

 

查看阵列信息

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

/dev/md1:

           Version : 1.2

     Creation Time : Mon Dec  7 09:44:00 2020

        Raid Level : raid1

        Array Size : 10476544 (9.99 GiB 10.73 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 2

     Total Devices : 3

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 09:58:26 2020

             State : clean

    Active Devices : 2

   Working Devices : 2

    Failed Devices : 1

     Spare Devices : 0

 

Consistency Policy : resync

 

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

              UUID : 6aa69cf9:255ef882:08b86b9a:679e6c6d

            Events : 36

 

    Number   Major   Minor   RaidDevice State

       0       8       48        0      active sync   /dev/sdd

       2       8       80        1      active sync   /dev/sdf

 

       1       8       64        -      faulty   /dev/sde

 

移除损坏磁盘

[root@localhost dev]# mdadm -r /dev/md1 /dev/sde

mdadm: hot removed /dev/sde from /dev/md1

 

查看阵列信息

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

/dev/md1:

           Version : 1.2

     Creation Time : Mon Dec  7 09:44:00 2020

        Raid Level : raid1

        Array Size : 10476544 (9.99 GiB 10.73 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 2

     Total Devices : 2

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 10:08:56 2020

             State : clean

    Active Devices : 2

   Working Devices : 2

    Failed Devices : 0

     Spare Devices : 0

 

Consistency Policy : resync

 

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

              UUID : 6aa69cf9:255ef882:08b86b9a:679e6c6d

            Events : 37

 

    Number   Major   Minor   RaidDevice State

       0       8       48        0      active sync   /dev/sdd

       2       8       80        1      active sync   /dev/sdf

 

添加新热备盘

[root@localhost dev]# mdadm -a /dev/md1 /dev/sde

mdadm: added /dev/sde

 

查看阵列信息

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

/dev/md1:

           Version : 1.2

     Creation Time : Mon Dec  7 09:44:00 2020

        Raid Level : raid1

        Array Size : 10476544 (9.99 GiB 10.73 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 2

     Total Devices : 3

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 10:10:38 2020

             State : clean

    Active Devices : 2

   Working Devices : 3

    Failed Devices : 0

     Spare Devices : 1

 

Consistency Policy : resync

 

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

              UUID : 6aa69cf9:255ef882:08b86b9a:679e6c6d

            Events : 38

 

    Number   Major   Minor   RaidDevice State

       0       8       48        0      active sync   /dev/sdd

       2       8       80        1      active sync   /dev/sdf

 

       3       8       64        -      spare   /dev/sde

 

RAID5

raid种类

磁盘

热备盘

raid5

sdgsdhsdi

sdj

raid5+1(raid5加一块热备盘)

对于raid5来说,只能增加成员盘,不能减少

创建RAID5

[root@localhost dev]# mdadm -C -v /dev/md5 -l 5 -n 3 -x 1 -c 32 /dev/sd{g,h,i,j}

mdadm: layout defaults to left-symmetric

mdadm: layout defaults to left-symmetric

mdadm: size set to 10476544K

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md5 started.

 

查看阵列信息

[root@localhost dev]# mdadm -D /dev/md5

/dev/md5:

           Version : 1.2

     Creation Time : Mon Dec  7 10:14:48 2020

        Raid Level : raid5

        Array Size : 20953088 (19.98 GiB 21.46 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 3

     Total Devices : 4

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 10:15:22 2020

             State : clean

    Active Devices : 3

   Working Devices : 4

    Failed Devices : 0

     Spare Devices : 1

 

            Layout : left-symmetric

        Chunk Size : 32K

 

Consistency Policy : resync

 

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

              UUID : 45aa0f62:e27c2059:6a8ca67a:9495335d

            Events : 18

 

    Number   Major   Minor   RaidDevice State

       0       8       96        0      active sync   /dev/sdg

       1       8      112        1      active sync   /dev/sdh

       4       8      128        2      active sync   /dev/sdi

 

       3       8      144        -      spare   /dev/sdj

 

将RAID5阵列信息保存到/etc/mdadm.conf配置文件中

[root@localhost dev]# mdadm -Dsv >> /etc/mdadm.conf

 

格式化阵列

[root@localhost dev]# mkfs.xfs /dev/md5

meta-data=/dev/md5               isize=512    agcount=16, agsize=327384 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0, sparse=0

data     =                       bsize=4096   blocks=5238144, imaxpct=25

         =                       sunit=8      swidth=16 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=8 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

 

阵列挂载

[root@localhost dev]# mkdir /dev/raid5

[root@localhost dev]# mount /dev/md5 /dev/raid5

 

查看阵列是否挂载成功

[root@localhost dev]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        55G  3.9G   51G   8% /

devtmpfs        3.8G     0  3.8G   0% /dev

tmpfs           3.9G     0  3.9G   0% /dev/shm

tmpfs           3.9G   13M  3.8G   1% /run

tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup

/dev/sda1       497M  166M  332M  34% /boot

tmpfs           781M  4.0K  781M   1% /run/user/42

tmpfs           781M   24K  781M   1% /run/user/0

/dev/md0         20G   33M   20G   1% /dev/raid_0

/dev/md1         10G   33M   10G   1% /dev/raid1

/dev/md5         20G   33M   20G   1% /dev/raid5

 

阵列开机自动挂载

文件名挂载

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

追加如下内容:

#raid_1_wenjian_guazai

/dev/md5        /dev/raid5     xfs     defaults        0 0

 

UUID挂载

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

/dev/md5: UUID="9906a44b-7cc1-4905-b651-e7ecbc07d531" TYPE="xfs"

 

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

追加如下内容:

#raid_1_UUID_guazai

UUID=2e4fbf9d-1dfc-4280-bc31-6a71c620508e /dev/raid1 xfs defaults 0 0

 

磁盘阵列扩容

查看是否同步

磁盘扩容前先确定数据是否同步完成。

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

/dev/md5:

           Version : 1.2

     Creation Time : Mon Dec  7 10:14:48 2020

        Raid Level : raid5

        Array Size : 20953088 (19.98 GiB 21.46 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 3

     Total Devices : 4

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 10:23:31 2020

             State : clean

    Active Devices : 3

   Working Devices : 4

    Failed Devices : 0

     Spare Devices : 1

 

            Layout : left-symmetric

        Chunk Size : 32K

 

Consistency Policy : resync         #下方有百分比,等待消失即同步完成。

 

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

              UUID : 45aa0f62:e27c2059:6a8ca67a:9495335d

            Events : 18

 

    Number   Major   Minor   RaidDevice State

       0       8       96        0      active sync   /dev/sdg

       1       8      112        1      active sync   /dev/sdh

       4       8      128        2      active sync   /dev/sdi

 

       3       8      144        -      spare   /dev/sdj

 

停止raid5阵列

[root@localhost ~]# mdadm -S /dev/md5

mdadm: Cannot get exclusive access to /dev/md5:Perhaps a running process, mounted filesystem or active volume group?

 

激活raid5阵列

[root@localhost ~]# mdadm -As

mdadm: Devices UUID-3e7915c3:206f4f2b:c1b0fc8f:54ea6e37 and UUID-3e7915c3:206f4f2b:c1b0fc8f:54ea6e37 have the same name: /dev/md0

mdadm: Duplicate MD device names in conf file were found.

 

热备盘增加到raid5

[root@localhost ~]# mdadm -G /dev/md5 -n 4 -c 32

 

将RAID5阵列信息保存到/etc/mdadm.conf配置文件中

[root@localhost ~]# mdadm -Dsv > /etc/mdadm.conf

 

查看阵列信息

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

/dev/md5:

           Version : 1.2

     Creation Time : Mon Dec  7 10:14:48 2020

        Raid Level : raid5

        Array Size : 20953088 (19.98 GiB 21.46 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 4

     Total Devices : 4

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 10:39:10 2020

             State : clean, reshaping

    Active Devices : 4

   Working Devices : 4

    Failed Devices : 0

     Spare Devices : 0

 

            Layout : left-symmetric

        Chunk Size : 32K

 

Consistency Policy : resync

 

    Reshape Status : 59% complete          #等待同步完成

     Delta Devices : 1, (3->4)

 

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

              UUID : 45aa0f62:e27c2059:6a8ca67a:9495335d

            Events : 51

 

    Number   Major   Minor   RaidDevice State

       0       8       96        0      active sync   /dev/sdg

       1       8      112        1      active sync   /dev/sdh

       4       8      128        2      active sync   /dev/sdi

       3       8      144        3      active sync   /dev/sdj

 

增加新热备盘

[root@localhost ~]# mdadm -a /dev/md5 /dev/sdk

mdadm: added /dev/sdk

 

查看阵列信息

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

/dev/md5:

           Version : 1.2

     Creation Time : Mon Dec  7 10:14:48 2020

        Raid Level : raid5

        Array Size : 31429632 (29.97 GiB 32.18 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 4

     Total Devices : 5

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 10:44:25 2020

             State : clean

    Active Devices : 4

   Working Devices : 5

    Failed Devices : 0

     Spare Devices : 1

 

            Layout : left-symmetric

        Chunk Size : 32K

 

Consistency Policy : resync

 

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

              UUID : 45aa0f62:e27c2059:6a8ca67a:9495335d

            Events : 56

 

    Number   Major   Minor   RaidDevice State

       0       8       96        0      active sync   /dev/sdg

       1       8      112        1      active sync   /dev/sdh

       4       8      128        2      active sync   /dev/sdi

       3       8      144        3      active sync   /dev/sdj

 

       5       8      160        -      spare   /dev/sdk

 

RAID6

 

 

 

 

RAID10

raid种类

磁盘

热备盘

raid10

sdlsdmsdnsdo

sdp

 

创建RAID10

[root@localhost dev]# mdadm -C -v /dev/md10 -l 10 -n 4 -c 32 /dev/sd{l,m,n,o}

mdadm: layout defaults to n2

mdadm: layout defaults to n2

mdadm: size set to 10476544K

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md10 started.

 

查看阵列信息

[root@localhost dev]# mdadm -D /dev/md10

/dev/md10:

           Version : 1.2

     Creation Time : Mon Dec  7 11:00:18 2020

        Raid Level : raid10

        Array Size : 20953088 (19.98 GiB 21.46 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 4

     Total Devices : 4

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 11:01:17 2020

             State : clean

    Active Devices : 4

   Working Devices : 4

    Failed Devices : 0

     Spare Devices : 0

 

            Layout : near=2

        Chunk Size : 32K

 

Consistency Policy : resync

 

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

              UUID : 5917f27e:5ef95178:53a013da:23d603ad

            Events : 17

 

    Number   Major   Minor   RaidDevice State

       0       8      176        0      active sync set-A   /dev/sdl

       1       8      192        1      active sync set-B   /dev/sdm

       2       8      208        2      active sync set-A   /dev/sdn

       3       8      224        3      active sync set-B   /dev/sdo

 

将RAID10阵列信息保存到/etc/mdadm.conf配置文件

[root@localhost dev]# mdadm -Dsv > /etc/mdadm.conf

 

格式化阵列

[root@localhost dev]# mkfs.xfs /dev/md10

meta-data=/dev/md10              isize=512    agcount=16, agsize=327384 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0, sparse=0

data     =                       bsize=4096   blocks=5238144, imaxpct=25

         =                       sunit=8      swidth=16 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal log           bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=8 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

 

阵列挂载

[root@localhost dev]# mkdir raid10

[root@localhost dev]# mount /dev/md10 /dev/raid10

 

查看阵列是否挂载成功

[root@localhost dev]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        55G  3.9G   51G   8% /

devtmpfs        3.8G     0  3.8G   0% /dev

tmpfs           3.9G     0  3.9G   0% /dev/shm

tmpfs           3.9G   13M  3.8G   1% /run

tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup

/dev/sda1       497M  166M  332M  34% /boot

tmpfs           781M  4.0K  781M   1% /run/user/42

tmpfs           781M   24K  781M   1% /run/user/0

/dev/md0         20G   33M   20G   1% /dev/raid_0

/dev/md1         10G   33M   10G   1% /dev/raid1

/dev/md5         20G   33M   20G   1% /dev/raid5

/dev/md10        20G   33M   20G   1% /dev/raid10

 

阵列开机自动挂载

文件名挂载

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

追加如下内容:

#raid_1_wenjian_guazai

/dev/md10        /dev/raid10     xfs     defaults        0 0

 

UUID挂载

查看UUID

[root@localhost dev]# blkid /dev/md10

/dev/md10: UUID="796de658-b357-464c-b1c8-4b4f641236ed" TYPE="xfs"

 

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

追加如下内容:

#raid_10_UUID_guazai

UUID=796de658-b357-464c-b1c8-4b4f641236ed /dev/raid10 xfs defaults 0 0

 

磁盘阵列扩容

添加新热备盘

[root@localhost dev]# mdadm -a /dev/md10 /dev/sdp

mdadm: added /dev/sdp

 

查看阵列信息

[root@localhost dev]# mdadm -D /dev/md10

/dev/md10:

           Version : 1.2

     Creation Time : Mon Dec  7 11:00:18 2020

        Raid Level : raid10

        Array Size : 20953088 (19.98 GiB 21.46 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 4

     Total Devices : 5

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 11:08:47 2020

             State : clean

    Active Devices : 4

   Working Devices : 5

    Failed Devices : 0

     Spare Devices : 1

 

            Layout : near=2

        Chunk Size : 32K

 

Consistency Policy : resync

 

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

              UUID : 5917f27e:5ef95178:53a013da:23d603ad

            Events : 18

 

    Number   Major   Minor   RaidDevice State

       0       8      176        0      active sync set-A   /dev/sdl

       1       8      192        1      active sync set-B   /dev/sdm

       2       8      208        2      active sync set-A   /dev/sdn

       3       8      224        3      active sync set-B   /dev/sdo

 

       4       8      240        -      spare   /dev/sdp

 

热备盘增加到raid10

[root@localhost dev]# mdadm -G /dev/md10 -n 5 -c 32

 

查看阵列信息

[root@localhost dev]# mdadm -D /dev/md10

/dev/md10:

           Version : 1.2

     Creation Time : Mon Dec  7 11:00:18 2020

        Raid Level : raid10

        Array Size : 20953088 (19.98 GiB 21.46 GB)

     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)

      Raid Devices : 5

     Total Devices : 5

       Persistence : Superblock is persistent

 

       Update Time : Mon Dec  7 11:11:38 2020

             State : clean, reshaping

    Active Devices : 5

   Working Devices : 5

    Failed Devices : 0

     Spare Devices : 0

 

            Layout : near=2

        Chunk Size : 32K

 

Consistency Policy : resync

 

    Reshape Status : 14% complete

     Delta Devices : 1, (4->5)

 

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

              UUID : 5917f27e:5ef95178:53a013da:23d603ad

            Events : 61

 

    Number   Major   Minor   RaidDevice State

       0       8      176        0      active sync   /dev/sdl

       1       8      192        1      active sync   /dev/sdm

       2       8      208        2      active sync   /dev/sdn

       3       8      224        3      active sync   /dev/sdo

       4       8      240        4      active sync   /dev/sdp

 

 

RAID50

 

 

 

 

 

软RAID删除

取消挂载

[root@localhost dev]# umount /dev/md0 /dev/raid_0

umount: /dev/raid_0: not mounted

 

查看挂载是否取消

[root@localhost dev]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        55G  3.9G   51G   8% /

devtmpfs        3.8G     0  3.8G   0% /dev

tmpfs           3.9G     0  3.9G   0% /dev/shm

tmpfs           3.9G   13M  3.8G   1% /run

tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup

/dev/sda1       497M  166M  332M  34% /boot

tmpfs           781M  4.0K  781M   1% /run/user/42

tmpfs           781M   24K  781M   1% /run/user/0

/dev/md1         10G   33M   10G   1% /dev/raid1

/dev/md5         20G   33M   20G   1% /dev/raid5

/dev/md10        20G   33M   20G   1% /dev/raid10

 

停止raid设备

[root@localhost dev]# mdadm -Ss /dev/md0

 

删除raid配置文件

[root@localhost dev]# vim /etc/mdadm.conf

删除如下信息:

ARRAY /dev/md0 level=raid0 num-devices=2 metadata=1.2 name=localhost.localdomain:0 UUID=3e7915c3:206f4f2b:c1b0fc8f:54ea6e37

   devices=/dev/sdb,/dev/sdc

 

清除磁盘raid标识

用到哪块磁盘就要清除他的raid标识

[root@localhost dev]# mdadm --zero-superblock /dev/sdb

[root@localhost dev]# mdadm --zero-superblock /dev/sdc