raid1
RAID-1 :mirroring(镜像卷)需要磁盘两块以上
原理:是把一个磁盘的数据镜像到另一个磁盘上,也就是说数据在写入一块磁盘的同时,会在另一块闲置的磁盘上生成镜像文件,(同步)
特性:当一块硬盘失效时,系统会忽略该硬盘,转而使用剩余的镜像盘读写数据,具备很好的磁盘冗余能力。
磁盘利用率为50%,即2块100G的磁盘构成RAID1只能提供100G的可用空间。
创建分区
[root@ 777 ~]# fdisk /dev/sdd
创建raid1
[root@ 777 ~]# mdadm -C -v /dev/md2 -l 1 -n 2 -x 1 /dev/sdd1 /dev/sdd[2,3]
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 3140608K
mdadm: largest drive (/dev/sdd1) exceeds size (3140608K) by more than 1%
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
将RAID1信息保存到配置文件中
[root@ 777 ~]# mdadm -Dsv > /etc/mdadm.conf
在raid设备上创建文件系统并挂载
[root@ 777 ~]# mkfs.xfs /dev/md2
meta-data=/dev/md2 isize=512 agcount=4, agsize=196288 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=785152, 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@centos7-xinsz08 ~]# mkdir /raid1
[root@centos7-xinsz08 ~]# mount /dev/md2 /raid1/
模拟损坏
[root@ 777 ~]# mdadm /dev/md2 -f /dev/sdd1
mdadm: set /dev/sdd1 faulty in /dev/md2
[root@ 777 ~]# mdadm -D /dev/md2
/dev/md2:
Version : 1.2
Creation Time : Thu Feb 27 16:24:39 2020
Raid Level : raid1
Array Size : 3140608 (3.00 GiB 3.22 GB)
Used Dev Size : 3140608 (3.00 GiB 3.22 GB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Thu Feb 27 16:31:48 2020
State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 1
Spare Devices : 1
Consistency Policy : resync
Rebuild Status : 88% complete
Name : centos7-xinsz08:2 (local to host centos7-xinsz08)
UUID : 5e197fe2:5c51970e:5e5288d5:e9066eb4
Events : 35
Number Major Minor RaidDevice State
2 8 51 0 spare rebuilding /dev/sdd3
1 8 50 1 active sync /dev/sdd2
0 8 49 - faulty /dev/sdd1
移除坏掉的设备
[root@centos7-xinsz08 raid1]# mdadm -r /dev/md2 /dev/sdd1
mdadm: hot removed /dev/sdd1 from /dev/md2
raid1中一块硬盘坏了不影响raid正常运行
使用率是50%
来源:CSDN
作者:Permission_777
链接:https://blog.csdn.net/Permission_777/article/details/104542328