Linux磁盘管理系列-软RAID的实现

存储 存储设备
RAID全称是独立磁盘冗余阵列(Redundant Array of Independent Disks),基本思想是把多个磁盘组合起来,组合一个磁盘阵列组,使得性能大幅提高。

1 什么是RAID

RAID全称是独立磁盘冗余阵列(Redundant Array of Independent Disks),基本思想是把多个磁盘组合起来,组合一个磁盘阵列组,使得性能大幅提高。

RAID分为几个不同的等级,各个不同的等级均在数据可靠性及读写性能做了不同的权衡。实际工作中根据自己的业务需求选择不同的RAID方案。 

2 RAID的实现方式

  • 外接式磁盘阵列:通过扩展卡提供适配能力
  • 内接式RAID:主板集成RAID控制器安装OS前在BIOS里配置
  • 软件RAID:通过OS实现

[[212458]]

3 标准的RAID

3.1 RAID0

RAID0称为条带化存储,将数据分段存储在各个磁盘中,读写均可以并行处理,因此读写速率为单个磁盘的N倍,没有冗余功能,任何一个磁盘的损坏就会导致的数据不可用。 

3.2 RAID1

RADI1是镜像存储,没有数据校验,数据被同等的写入到2个或者多个磁盘中,写入速度相对慢, 但是读取速度比较快。 

3.3 RAID 4

RADI4在RAID1的基础上,N个盘用于数据存储,另外加入了1个磁盘作为校验盘。一共N+1个盘,任何一个盘坏掉也不影响数据的访问

3.4 RAID 5

RAID5在RAID4的基础上,由原来的一个盘来存储校验数据,改为每个盘都有数据和校验信息的。 

4 混合RAID

4.1 RAID01

先组成RAID0,然后组成RAID1.

4.2 RAID10

先组成RAID1,然后组成RAID0

5 软RAID的实现

5.1 RAID5的实现

创建由三块硬盘组成的可用空间为2G的RAID5设备,要求其chunk大小为256k,文件系统为ext4,开机可自动挂载至/mydata目录

5.1.1 先看看我们的磁盘情况

  1. [root@centos7 Bash]$ lsblk 
  2. NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
  3. sda      8:0    0  200G  0 disk 
  4. ├─sda1   8:1    0    1G  0 part /boot 
  5. ├─sda2   8:2    0  128G  0 part 
  6. ├─sda3   8:3    0 48.8G  0 part / 
  7. ├─sda4   8:4    0  512B  0 part 
  8. └─sda5   8:5    0 19.5G  0 part /app 
  9. sdb      8:16   0  100G  0 disk 
  10. sdc      8:32   0   20G  0 disk 
  11. sdd      8:48   0   20G  0 disk 
  12. sde      8:64   0   20G  0 disk 
  13. sdf      8:80   0   20G  0 disk 
  14. sr0     11:0    1  8.1G  0 rom  /run/media/root/CentOS 7 x86_64  

这里我们使用sdb,sdc,sdd,每个盘创建一个主分区1G,构建RADI5.

5.1.2 根据实际情况分区

  1. [root@centos7 Bash]$ fdisk /dev/sdb 
  2. Welcome to fdisk (util-linux 2.23.2). 
  3.  
  4. Changes will remain in memory only, until you decide to write them. 
  5. Be careful before using the write command. 
  6.  
  7. Device does not contain a recognized partition table 
  8. Building a new DOS disklabel with disk identifier 0x93d380cf. 
  9.  
  10. Command (m for help): n 
  11. Partition type: 
  12.    p   primary (0 primary, 0 extended, 4 free
  13.    e   extended 
  14. Select (default p): p 
  15. Partition number (1-4, default 1):  
  16. First sector (2048-209715199, default 2048):  
  17. Using default value 2048 
  18. Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +1G 
  19. Partition 1 of type Linux and of size 1 GiB is set 
  20.  
  21. Command (m for help): t 
  22. Selected partition 1 
  23. Hex code (type L to list all codes): fd 
  24. Changed type of partition 'Linux' to 'Linux raid autodetect' 
  25.  
  26. Command (m for help): p 
  27.  
  28. Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors 
  29. Units = sectors of 1 * 512 = 512 bytes 
  30. Sector size (logical/physical): 512 bytes / 512 bytes 
  31. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  32. Disk label type: dos 
  33. Disk identifier: 0x93d380cf 
  34.  
  35.    Device Boot      Start         End      Blocks   Id  System 
  36. /dev/sdb1            2048     2099199     1048576   fd  Linux raid autodetect 
  37.  
  38. Command (m for help): w 
  39. The partition table has been altered! 
  40.  
  41. Calling ioctl() to re-read partition table
  42. Syncing disks. 
  43. [root@centos7 Bash]$ fdisk /dev/sdc 
  44. Welcome to fdisk (util-linux 2.23.2). 
  45.  
  46. Changes will remain in memory only, until you decide to write them. 
  47. Be careful before using the write command. 
  48.  
  49. Device does not contain a recognized partition table 
  50. Building a new DOS disklabel with disk identifier 0xc56b90d8. 
  51.  
  52. Command (m for help): n 
  53. Partition type: 
  54.    p   primary (0 primary, 0 extended, 4 free
  55.    e   extended 
  56. Select (default p): p 
  57. Partition number (1-4, default 1):  
  58. First sector (2048-41943039, default 2048):  
  59. Using default value 2048 
  60. Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G 
  61. Partition 1 of type Linux and of size 1 GiB is set 
  62.  
  63. Command (m for help): t 
  64. Selected partition 1 
  65. Hex code (type L to list all codes): fd 
  66. Changed type of partition 'Linux' to 'Linux raid autodetect' 
  67.  
  68. Command (m for help): p 
  69.  
  70. Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors 
  71. Units = sectors of 1 * 512 = 512 bytes 
  72. Sector size (logical/physical): 512 bytes / 512 bytes 
  73. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  74. Disk label type: dos 
  75. Disk identifier: 0xc56b90d8 
  76.  
  77.    Device Boot      Start         End      Blocks   Id  System 
  78. /dev/sdc1            2048     2099199     1048576   fd  Linux raid autodetect 
  79.  
  80. Command (m for help): w 
  81. The partition table has been altered! 
  82.  
  83. Calling ioctl() to re-read partition table
  84. Syncing disks. 
  85. [root@centos7 Bash]$ fdisk /dev/sdd 
  86. Welcome to fdisk (util-linux 2.23.2). 
  87.  
  88. Changes will remain in memory only, until you decide to write them. 
  89. Be careful before using the write command. 
  90.  
  91. Device does not contain a recognized partition table 
  92. Building a new DOS disklabel with disk identifier 0x7e0900d8. 
  93.  
  94. Command (m for help): n 
  95. Partition type: 
  96.    p   primary (0 primary, 0 extended, 4 free
  97.    e   extended 
  98. Select (default p): p 
  99. Partition number (1-4, default 1):  
  100. First sector (2048-41943039, default 2048):  
  101. Using default value 2048 
  102. Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G 
  103. Partition 1 of type Linux and of size 1 GiB is set 
  104.  
  105. Command (m for help): p 
  106.  
  107. Disk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors 
  108. Units = sectors of 1 * 512 = 512 bytes 
  109. Sector size (logical/physical): 512 bytes / 512 bytes 
  110. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  111. Disk label type: dos 
  112. Disk identifier: 0x7e0900d8 
  113.  
  114.    Device Boot      Start         End      Blocks   Id  System 
  115. /dev/sdd1            2048     2099199     1048576   83  Linux 
  116.  
  117. Command (m for help): t 
  118. Selected partition 1 
  119. Hex code (type L to list all codes): fd 
  120. Changed type of partition 'Linux' to 'Linux raid autodetect' 
  121.  
  122. Command (m for help): w 
  123. The partition table has been altered! 
  124.  
  125. Calling ioctl() to re-read partition table
  126. Syncing disks. 

5.1.3 创建raid

  1. [root@centos7 Bash]$ mdadm -C /dev/md5 -a yes -l 5 -n 3 /dev/sd{b1,c1,d1} -c 256       # -C指定创建, -a yes 自动创建设备 , -l 设定level , -n 设定磁盘个数, -c chunk大小 
  2. Continue creating array? y 
  3. mdadm: Defaulting to version 1.2 metadata 
  4. mdadm: array /dev/md5 started. 
  5. [root@centos7 Bash]$ mdadm -Ds                                                          # 查看信息 
  6. ARRAY /dev/md5 metadata=1.2 name=centos7.magedu.com:5 UUID=2c8ae60d:a799fcb7:9008a046:ae6ea430 
  7. [root@centos7 Bash]$ mdadm -Ds >/etc/mdadm.conf                                         # 将软raid信息写入到配置文件中去 
  8. [root@centos7 Bash]$ mkdir /mnt/md5                                                     # 创建挂载点目录  
  9. [root@centos7 Bash]$ mkfs.ext4 /dev/md5                                                 # 创建文件系统 
  10. mke2fs 1.42.9 (28-Dec-2013) 
  11. Filesystem label= 
  12. OS type: Linux 
  13. Block size=4096 (log=2) 
  14. Fragment size=4096 (log=2) 
  15. Stride=64 blocks, Stripe width=128 blocks 
  16. 131072 inodes, 523776 blocks 
  17. 26188 blocks (5.00%) reserved for the super user 
  18. First data block=0 
  19. Maximum filesystem blocks=536870912 
  20. 16 block groups 
  21. 32768 blocks per group, 32768 fragments per group 
  22. 8192 inodes per group 
  23. Superblock backups stored on blocks:  
  24.     32768, 98304, 163840, 229376, 294912 
  25.  
  26. Allocating group tables: done                             
  27. Writing inode tables: done                             
  28. Creating journal (8192 blocks): done 
  29. Writing superblocks and filesystem accounting information: done  
  30.  
  31. [root@centos7 Bash]$ mount /dev/md5 /mnt/md5                                          # 挂载设备  
  32. [root@centos7 Bash]$ tail -n 1 /etc/mtab 
  33. /dev/md5 /mnt/md5 ext4 rw,seclabel,relatime,stripe=128,data=ordered 0 0               # 查看挂载信息 
  34. [root@centos7 Bash]$ tail -n 1 /etc/mtab >>/etc/fstab        

5.1.4 验证raid

  1. [root@centos7 md5]$ mdadm -D /dev/md5                                                 #查看详细raid5详细信息,可以发现有3个都是working状态的 
  2. /dev/md5: 
  3.            Version : 1.2 
  4.      Creation Time : Wed Dec  6 19:28:22 2017 
  5.         Raid Level : raid5 
  6.         Array Size : 2095104 (2046.00 MiB 2145.39 MB) 
  7.      Used Dev Size : 1047552 (1023.00 MiB 1072.69 MB) 
  8.       Raid Devices : 3 
  9.      Total Devices : 3 
  10.        Persistence : Superblock is persistent 
  11.  
  12.        Update Time : Wed Dec  6 19:39:06 2017 
  13.              State : clean  
  14.     Active Devices : 3 
  15.    Working Devices : 3 
  16.     Failed Devices : 0 
  17.      Spare Devices : 0 
  18.  
  19.             Layout : left-symmetric 
  20.         Chunk Size : 256K 
  21.  
  22. Consistency Policy : resync 
  23.  
  24.               Name : centos7.magedu.com:5  (local to host centos7.magedu.com) 
  25.               UUID : 2c8ae60d:a799fcb7:9008a046:ae6ea430 
  26.             Events : 18 
  27.  
  28.     Number   Major   Minor   RaidDevice State 
  29.        0       8       17        0      active sync   /dev/sdb1 
  30.        1       8       33        1      active sync   /dev/sdc1 
  31.        3       8       49        2      active sync   /dev/sdd1 
  32. [root@centos7 md5]$ man mdadm 
  33. [root@centos7 md5]$ mdadm /dev/md5 -f /dev/sdc1                                                 # -f 设定指定设备故障, 将/dev/sdc1 这个盘标记失败, 看是否数据能访问,我这里使用-f标记失败,工作中可以根据硬盘指示灯判断磁盘状态 
  34. mdadm: set /dev/sdc1 faulty in /dev/md5             
  35. [root@centos7 md5]$ mdadm -D /dev/md5                                                           #在次查看信息,发现工作的是2个, 一个失败的设备  
  36. /dev/md5: 
  37.            Version : 1.2 
  38.      Creation Time : Wed Dec  6 19:28:22 2017 
  39.         Raid Level : raid5 
  40.         Array Size : 2095104 (2046.00 MiB 2145.39 MB) 
  41.      Used Dev Size : 1047552 (1023.00 MiB 1072.69 MB) 
  42.       Raid Devices : 3 
  43.      Total Devices : 3 
  44.        Persistence : Superblock is persistent 
  45.  
  46.        Update Time : Wed Dec  6 19:41:08 2017 
  47.              State : clean, degraded                                                             # 这里注意了。 我们的一个盘坏掉了。 raid5状态为降级使用了。 
  48.     Active Devices : 2 
  49.    Working Devices : 2 
  50.     Failed Devices : 1 
  51.      Spare Devices : 0 
  52.  
  53.             Layout : left-symmetric 
  54.         Chunk Size : 256K 
  55.  
  56. Consistency Policy : resync 
  57.  
  58.               Name : centos7.magedu.com:5  (local to host centos7.magedu.com) 
  59.               UUID : 2c8ae60d:a799fcb7:9008a046:ae6ea430 
  60.             Events : 20 
  61.  
  62.     Number   Major   Minor   RaidDevice State 
  63.        0       8       17        0      active sync   /dev/sdb1 
  64.        -       0        0        1      removed 
  65.        3       8       49        2      active sync   /dev/sdd1 
  66.  
  67.        1       8       33        -      faulty   /dev/sdc1 
  68. [root@centos7 md5]$ cat a.txt                                          # 发现我们的数据还是能访问的。没有问题。 

5.1.5 替换设备

我这里是磁盘坏掉后的执行替换的, 完全可以多一个备用盘, 坏掉自动替换的。

  1. [root@centos7 md5]$ mdadm /dev/md5 -a /dev/sde1                        # 上面我们的sdc1数据损坏,我们需要更换新的磁盘来顶替他的位置。这里添加一个sde1的磁盘, fdisk操作这里省去了。 
  2. mdadm: added /dev/sde1 
  3. [root@centos7 md5]$ mdadm -Ds                                          # 查看详细信息 
  4. ARRAY /dev/md5 metadata=1.2 name=centos7.magedu.com:5 UUID=2c8ae60d:a799fcb7:9008a046:ae6ea430 
  5. [root@centos7 md5]$ mdadm -D /dev/md5                                  # 查看详细信息 
  6. /dev/md5: 
  7.            Version : 1.2 
  8.      Creation Time : Wed Dec  6 19:28:22 2017 
  9.         Raid Level : raid5 
  10.         Array Size : 2095104 (2046.00 MiB 2145.39 MB) 
  11.      Used Dev Size : 1047552 (1023.00 MiB 1072.69 MB) 
  12.       Raid Devices : 3 
  13.      Total Devices : 4 
  14.        Persistence : Superblock is persistent 
  15.  
  16.        Update Time : Wed Dec  6 19:50:01 2017 
  17.              State : clean                                                  # 状态恢复正常了。没有问题 
  18.     Active Devices : 3 
  19.    Working Devices : 3 
  20.     Failed Devices : 1 
  21.      Spare Devices : 0 
  22.  
  23.             Layout : left-symmetric 
  24.         Chunk Size : 256K 
  25.  
  26. Consistency Policy : resync 
  27.  
  28.               Name : centos7.magedu.com:5  (local to host centos7.magedu.com) 
  29.               UUID : 2c8ae60d:a799fcb7:9008a046:ae6ea430 
  30.             Events : 43 
  31.  
  32.     Number   Major   Minor   RaidDevice State 
  33.        0       8       17        0      active sync   /dev/sdb1 
  34.        4       8       65        1      active sync   /dev/sde1 
  35.        3       8       49        2      active sync   /dev/sdd1 
  36.  
  37.        1       8       33        -      faulty   /dev/sdc1             # 这个盘是坏掉的,我们已经加入了新的磁盘, 这个盘可以干掉了 
  38. [root@centos7 md5]$ man mdadm 
  39. [root@centos7 md5]$ mdadm /dev/md5 --remove /dev/sdc1                  # 这个盘我们从raid5中移除去。         
  40. mdadm: hot removed /dev/sdc1 from /dev/md5 

5.1.6扩展raid

我们上面使用的是2+1构成的raid5,磁盘利用率为66%,如果我们想改成3+1 可以执行类似如下命令

  1. [root@centos7 mnt]$ mkadm -G -r  /dev/md5 -n 4 -a /dev/sdxx                  # 这里我就不测试了。使用/dev/sdxx代替一个设备。-G 是Grown增长的意思,-r 是resizefs的意思, 

5.1.7 清空raid信息

  1. [root@centos7 mnt]$ umount /dev/md5                                   # 卸载设备 
  2. [root@centos7 mnt]$ mdadm -S /dev/md5                                 # 停止raid5  
  3. mdadm: stopped /dev/md5 
  4. [root@centos7 mnt]$ sed -i '$d' /etc/fstab                            # 删除fstab中关于raid5挂载的行 
  5. [root@centos7 mnt]$ cat /etc/fstab                                    # 确保fstab没有大问题 
  6.  
  7. # /etc/fstab 
  8. # Created by anaconda on Tue Nov  7 16:07:01 2017 
  9. # Accessible filesystems, by reference, are maintained under '/dev/disk' 
  10. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info 
  11.  
  12. UUID=59ccea87-3c4e-4bbc-9e2f-3fadb1dcf2e6 /                       ext4    defaults        1 1 
  13. UUID=f4e867e8-bcde-43a2-adc7-c80b0948e85f /app                    ext4    noatime,usrquota,grpquota        1 2 
  14. UUID=1d6cbe88-ffb4-4adf-bacf-76be1fa75708 /boot                   ext4    defaults        1 2 
  15. #UUID=b2c064f5-1ee5-4b5c-9e75-ed41cb99c5aa swap                    swap    defaults        0 0 
  16. #UUID=a0516c4f-40e6-4919-905a-8b44db12ff7b swap               swap    defaults,pri=0        0 0  
  17. #/dev/sdb2 /test ext4 rw,seclabel,relatime,data=ordered 0 0 
  18. #/dev/sdb1 /home xfs rw,seclabel,relatime,attr2,inode64,usrquota,grpquota  0 0 
  19. [root@centos7 mnt]$ rm -rf /etc/mdadm.conf                                   # 删除raid默认配置文件 
  20. [root@centos7 mnt]$ mdadm --zero-superblock /dev/sd{b1,e1,d1,c1}             # 清空设置上的超级块信息 

5.2 RAID10的实现

raid10 ,6个分区,2个一组raid1,3组raid0 

5.2.1 案例分析

分析下,我们创建一个raid10设置,2个设备组成一个raid1,6个设备2个一组可以组成3个raid1, 然后把3个raid1组成一个raid0即可

5.2.2 先创建6个设备

  1. [root@centos7 mnt]$ lsblk                                # 就是使用fdisk 创建的设备, 具体这里就不写了。 最终使用lsblk显示,我们可以看到sdb1,sdb2,sdd1,sde1一共6个磁盘 
  2. NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
  3. sda      8:0    0  200G  0 disk  
  4. ├─sda1   8:1    0    1G  0 part /boot 
  5. ├─sda2   8:2    0  128G  0 part  
  6. ├─sda3   8:3    0 48.8G  0 part / 
  7. ├─sda4   8:4    0  512B  0 part  
  8. └─sda5   8:5    0 19.5G  0 part /app 
  9. sdb      8:16   0  100G  0 disk  
  10. ├─sdb1   8:17   0    1G  0 part  
  11. └─sdb2   8:18   0    1G  0 part  
  12. sdc      8:32   0   20G  0 disk  
  13. ├─sdc1   8:33   0    1G  0 part  
  14. └─sdc2   8:34   0    1G  0 part  
  15. sdd      8:48   0   20G  0 disk  
  16. └─sdd1   8:49   0    1G  0 part  
  17. sde      8:64   0   20G  0 disk  
  18. └─sde1   8:65   0    1G  0 part  
  19. sdf      8:80   0   20G  0 disk  
  20. sr0     11:0    1  8.1G  0 rom  /run/media/root/CentOS 7 x86_64 

5.2.3 创建raid 

  1. [root@centos7 mnt]$ mdadm -C /dev/md11 -a yes -l 1 -n 2 /dev/sd{b1,c1}                               # 创建***个raid1 
  2. mdadm: /dev/sdb1 appears to be part of a raid array: 
  3.        level=raid5 devices=3 ctime=Wed Dec  6 19:28:22 2017 
  4. mdadm: Note: this array has metadata at the start and 
  5.     may not be suitable as a boot device.  If you plan to 
  6.     store '/boot' on this device please ensure that 
  7.     your boot-loader understands md/v1.x metadata, or use 
  8.     --metadata=0.90 
  9. mdadm: /dev/sdc1 appears to be part of a raid array: 
  10.        level=raid5 devices=3 ctime=Wed Dec  6 19:28:22 2017 
  11. Continue creating array? y 
  12. mdadm: Defaulting to version 1.2 metadata 
  13. mdadm: array /dev/md11 started. 
  14. [root@centos7 mnt]$ mdadm -C /dev/md12 -a yes -l 1 -n 2 /dev/sd{b2,c2}                                #创建第二个raid1 
  15. mdadm: Note: this array has metadata at the start and 
  16.     may not be suitable as a boot device.  If you plan to 
  17.     store '/boot' on this device please ensure that 
  18.     your boot-loader understands md/v1.x metadata, or use 
  19.     --metadata=0.90 
  20. Continue creating array? y 
  21. mdadm: Defaulting to version 1.2 metadata 
  22. mdadm: array /dev/md12 started. 
  23. [root@centos7 mnt]$ mdadm -C /dev/md13 -a yes -l 1 -n 2 /dev/sd{d1,e1}                                 # 创建第三个raid1 
  24. mdadm: /dev/sdd1 appears to be part of a raid array: 
  25.        level=raid5 devices=3 ctime=Wed Dec  6 19:28:22 2017 
  26. mdadm: Note: this array has metadata at the start and 
  27.     may not be suitable as a boot device.  If you plan to 
  28.     store '/boot' on this device please ensure that 
  29.     your boot-loader understands md/v1.x metadata, or use 
  30.     --metadata=0.90 
  31. mdadm: /dev/sde1 appears to be part of a raid array: 
  32.        level=raid5 devices=3 ctime=Wed Dec  6 19:28:22 2017 
  33. Continue creating array? y 
  34. mdadm: Defaulting to version 1.2 metadata 
  35. mdadm: array /dev/md13 started. 
  36. [root@centos7 mnt]$ mdadm -C /dev/md10 -a yes -l 0 -n 3 /dev/md{11,12,13}                             # 将3个raid1 合并为一个raid0  
  37. mdadm: /dev/md11 appears to contain an ext2fs file system 
  38.        size=2095104K  mtime=Wed Dec  6 19:29:45 2017 
  39. mdadm: /dev/md13 appears to contain an ext2fs file system 
  40.        size=2095104K  mtime=Wed Dec  6 19:29:45 2017 
  41. Continue creating array? y 
  42. mdadm: Defaulting to version 1.2 metadata 
  43. mdadm: array /dev/md10 started. 
  44. [root@centos7 mnt]$ mkfs.ext 
  45. mkfs.ext2  mkfs.ext3  mkfs.ext4             
  46. [root@centos7 mnt]$ mkfs.ext4 /dev/md10                                                                 # 创建文件系统                                                                                          
  47. mke2fs 1.42.9 (28-Dec-2013) 
  48. Filesystem label= 
  49. OS type: Linux 
  50. Block size=4096 (log=2) 
  51. Fragment size=4096 (log=2) 
  52. Stride=128 blocks, Stripe width=384 blocks 
  53. 196224 inodes, 784896 blocks 
  54. 39244 blocks (5.00%) reserved for the super user 
  55. First data block=0 
  56. Maximum filesystem blocks=805306368 
  57. 24 block groups 
  58. 32768 blocks per group, 32768 fragments per group 
  59. 8176 inodes per group 
  60. Superblock backups stored on blocks:  
  61.     32768, 98304, 163840, 229376, 294912 
  62.  
  63. Allocating group tables: done                             
  64. Writing inode tables: done                             
  65. Creating journal (16384 blocks): done 
  66. Writing superblocks and filesystem accounting information: done  
  67.  
  68. [root@centos7 mnt]$ mdadm -Ds                                                                             # 查看配置信息 
  69. ARRAY /dev/md11 metadata=1.2 name=centos7.magedu.com:11 UUID=0ce2cd6c:cd21fab6:3e65cfb5:64bd86f3 
  70. ARRAY /dev/md12 metadata=1.2 name=centos7.magedu.com:12 UUID=8af31dff:efab06ed:48e2613b:a599c774 
  71. ARRAY /dev/md13 metadata=1.2 name=centos7.magedu.com:13 UUID=a8c99d60:2d0c61e7:97a76809:9396c020 
  72. ARRAY /dev/md10 metadata=1.2 name=centos7.magedu.com:10 UUID=50b2fa58:4ce65d67:8c50c853:fa175a28 
  73. [root@centos7 mnt]$ mdadm -Ds  >> /etc/mdadm.conf                                                         # 写配置文件到mdadm的配置文件中 
  74. [root@centos7 mnt]$ mkdir /mnt/md10                                                                       # 创建挂载目录 
  75. [root@centos7 mnt]$ mount /dev/md10 /mnt/md10                                                             # 挂载文件系统 
  76. [root@centos7 mnt]$ tail -n 1 /etc/mtab                                                                   # 查看mtab文件中的***一行, 也就是我们的md10挂载信息 
  77. /dev/md10 /mnt/md10 ext4 rw,seclabel,relatime,stripe=384,data=ordered 0 0 
  78. [root@centos7 mnt]$ tail -n 1 /etc/mtab >> /etc/fstab                                                     #添加到开机启动 

5.2.4 raid 清除工作

  1. [root@centos7 mnt]$ umount /dev/md10                                                                      # 取消挂载 
  2. [root@centos7 mnt]$ rm -rf /etc/mdadm.conf                                                                # 删除mdadm的默认配置 
  3. [root@centos7 mnt]$ mdadm -S /dev/md10                                                                    # 停止raid0设置 
  4. mdadm: stopped /dev/md10 
  5. [root@centos7 mnt]$ mdadm -S /dev/md11                                                                    # 停止raid1设置 
  6. mdadm: stopped /dev/md11 
  7. [root@centos7 mnt]$ mdadm -S /dev/md12                                                                    # 停止radi1 设置 
  8. mdadm: stopped /dev/md12  
  9. [root@centos7 mnt]$ mdadm -S /dev/md13                                                                    # 停止raid 1 设置 
  10. mdadm: stopped /dev/md13 
  11. [root@centos7 mnt]$ sed -i '$d' /etc/fstab                                                                # 删除fstab的挂载   
  12. [root@centos7 mnt]$ cat /etc/fstab                                                                        # 确保正确 
  13.  
  14. # /etc/fstab 
  15. # Created by anaconda on Tue Nov  7 16:07:01 2017 
  16. # Accessible filesystems, by reference, are maintained under '/dev/disk' 
  17. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info 
  18.  
  19. UUID=59ccea87-3c4e-4bbc-9e2f-3fadb1dcf2e6 /                       ext4    defaults        1 1 
  20. UUID=f4e867e8-bcde-43a2-adc7-c80b0948e85f /app                    ext4    noatime,usrquota,grpquota        1 2 
  21. UUID=1d6cbe88-ffb4-4adf-bacf-76be1fa75708 /boot                   ext4    defaults        1 2 
  22. #UUID=b2c064f5-1ee5-4b5c-9e75-ed41cb99c5aa swap                    swap    defaults        0 0 
  23. #UUID=a0516c4f-40e6-4919-905a-8b44db12ff7b swap               swap    defaults,pri=0        0 0  
  24. #/dev/sdb2 /test ext4 rw,seclabel,relatime,data=ordered 0 0 
  25. #/dev/sdb1 /home xfs rw,seclabel,relatime,attr2,inode64,usrquota,grpquota  0 0 
  26. [root@centos7 mnt]$ mdadm -D                                                                                  # 再次查看下mdadm信息,确保没有了 
  27. mdadm: No devices given. 
  28. [root@centos7 mnt]$ mdadm --zero-superblock /dev/sd{b1,b2,c1,c2,d1,e1}                                        # 请求md的元数据信息 

 

责任编辑:武晓燕 来源: 博客园
相关推荐

2018-05-14 09:28:24

RAID磁盘存储

2017-08-17 08:59:40

磁盘RAIDShell

2017-08-17 09:32:03

RAID磁盘阵列

2011-01-11 13:53:33

Linux管理磁盘

2015-08-27 10:19:31

LinuxRAID

2009-01-09 22:33:19

服务器磁盘RAID

2018-03-07 10:17:59

磁盘阵列RAID模式

2024-01-04 12:05:22

LinuxRAID技术

2018-12-06 10:40:50

磁盘缓存内存

2013-06-28 10:12:20

Linux软Raid自动重组

2018-09-20 10:37:56

RAID技术磁盘阵列

2017-09-06 08:43:18

RAID磁盘阵列

2010-03-10 18:29:41

2019-02-11 14:50:21

Linux分区命令

2016-09-13 18:12:53

RAID存储技术

2018-02-06 08:48:52

RAID5磁盘阵列修复

2009-10-22 11:36:31

linux磁盘管理

2009-10-22 10:59:29

linux磁盘命令

2014-10-10 14:34:17

RAID 10Linux

2018-08-16 10:47:53

raid0磁盘阵列双硬盘
点赞
收藏

51CTO技术栈公众号