RAID5部署
软RAID与备份盘
1.此处我们还用刚才的4块盘做演示,三块盘做raid,一块盘做备份盘,防止磁盘故障
我们以raid 5 来配置三块磁盘 加上一块备份盘
[root@local-pyyu tmp]# mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 5237760K
mdadm: Fail create md0 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
2.检查raid状态
[root@local-pyyu tmp]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Dec 6 15:47:46 2019
Raid Level : raid5
Array Size : 10475520 (9.99 GiB 10.73 GB)
Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Fri Dec 6 15:48:12 2019
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : local-pyyu:0 (local to host local-pyyu)
UUID : 76645a7d:74bc7aca:6b5c214d:f72ecb0f
Events : 18
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
4 8 48 2 active sync /dev/sdd
3 8 64 - spare /dev/sde
格式化磁盘文件系统
[root@local-pyyu tmp]# mkfs.xfs -f /dev/md0
meta-data=/dev/md0 isize=512 agcount=16, agsize=163712 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2618880, 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@local-pyyu tmp]# mount /dev/md0 /chaogeRAID5/
检查挂载情况
[root@local-pyyu tmp]# mount |grep md0
/dev/md0 on /chaogeRAID5 type xfs (rw,relatime,attr2,inode64,sunit=1024,swidth=2048,noquota)
[root@local-pyyu chaogeRAID5]# df -h|grep md0
/dev/md0 10G 33M 10G 1% /chaogeRAID5
写入数据
[root@local-pyyu chaogeRAID5]# echo {1..10000000} > ceshi.txt
[root@local-pyyu chaogeRAID5]# df -h
见证备份磁盘的作用
1.此时raid中的磁盘情况
[root@local-pyyu chaogeRAID5]# mdadm -D /dev/md0 |grep sd
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
4 8 48 2 active sync /dev/sdd
3 8 64 - spare /dev/sde
2.剔除一块磁盘
[root@local-pyyu chaogeRAID5]# mdadm /dev/md0 -f /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md0
3.惊喜的发现,备份磁盘上来了
[root@local-pyyu chaogeRAID5]# mdadm -D /dev/md0 |grep sd
3 8 64 0 spare rebuilding /dev/sde
1 8 32 1 active sync /dev/sdc
4 8 48 2 active sync /dev/sdd
0 8 16 - faulty /dev/sdb
4.磁盘已然可以用