//将硬盘设备/dev/sdb移除磁盘阵列[root@centos ~]# mdadm /dev/md5 -f /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md5
//查看/dev/md0磁盘阵列的详细信息[root@centos ~]# mdadm -D /dev/md5
/dev/md5:Version :1.2Creation Time : Thu Apr 2718:14:092023Raid Level : raid5Array Size :41908224(39.97 GiB 42.91 GB)Used Dev Size :20954112(19.98 GiB 21.46 GB)Raid Devices :3Total Devices :4Persistence : Superblock is persistentUpdate Time : Thu Apr 2718:23:312023State : clean, degraded, recovering Active Devices :2Working Devices :3Failed Devices :1Spare Devices :1Layout : left-symmetricChunk Size :512KConsistency Policy : resyncRebuild Status :69% completeName : centos:5(local to host centos)UUID :279cba83:dcd23661:cbd67fac:8bae8d86Events :31Number Major Minor RaidDevice State38640 active sync /dev/sde18321 active sync /dev/sdc48482 active sync /dev/sdd0816- faulty /dev/sdb
4、删除磁盘阵列
(1)、卸载
[root@centos ~]# umount /RAID
(2)、模拟损坏硬盘并删除
[root@centos ~]# mdadm /dev/md5 -f /dev/sdb -r /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md5
mdadm: hot removed /dev/sdb from /dev/md5
[root@centos ~]# mdadm /dev/md5 -f /dev/sdc -r /dev/sdc
mdadm: set /dev/sdc faulty in /dev/md5
mdadm: hot removed /dev/sdc from /dev/md5
[root@centos ~]# mdadm /dev/md5 -f /dev/sdd -r /dev/sdd
mdadm: set /dev/sdd faulty in /dev/md5
mdadm: hot removed /dev/sdd from /dev/md5
[root@centos ~]# mdadm /dev/md5 -f /dev/sde -r /dev/sde
mdadm: set /dev/sde faulty in /dev/md5
mdadm: hot removed /dev/sde from /dev/md5
(3)、查看详细信息
[root@centos ~]# mdadm -D /dev/md5
/dev/md5:Version :1.2Creation Time : Thu Apr 2718:14:092023Raid Level : raid5Array Size :41908224(39.97 GiB 42.91 GB)Used Dev Size :20954112(19.98 GiB 21.46 GB)Raid Devices :3Total Devices :0Persistence : Superblock is persistentUpdate Time : Thu Apr 2718:27:362023State : clean, degraded Active Devices :0Working Devices :0Failed Devices :0Spare Devices :0Layout : left-symmetricChunk Size :512KConsistency Policy : resyncName : centos:5(local to host centos)UUID :279cba83:dcd23661:cbd67fac:8bae8d86Events :41Number Major Minor RaidDevice State-000 removed-001 removed-002 removed
//将硬盘添加到storage卷组
[root@centos ~]# vgcreate storage /dev/sdb /dev/sdcVolume group "storage" successfully created
//查看卷组状态
[root@centos ~]# vgdisplay storage --- Volume group ---VG Name storageSystem ID Format lvm2Metadata Areas 2Metadata Sequence No 1VG Access read/writeVG Status resizableMAX LV 0Cur LV 0Open LV 0Max PV 0Cur PV 2Act PV 2VG Size 39.99 GiBPE Size 4.00 MiBTotal PE 10238Alloc PE / Size 0 / 0 Free PE / Size 10238 / 39.99 GiBVG UUID GImCki-hscS-une3-74Xa-XOkz-2JhH-ugaUdU
(4)、创建逻辑卷并查看状态
//分割一个约150MB的逻辑卷设备[root@centos ~]# lvcreate -n vo -L 150MB storage Rounding up size to full physical extent 152.00 MiBLogical volume "vo" created.[root@centos ~]# lvdisplay --- Logical volume ---LV Path /dev/storage/voLV Name voVG Name storageLV UUID 4VinRD-jJfs-s0Pe-Wva1-9kAX-QUAd-Vjq2MSLV Write Access read/writeLV Creation host, time centos,2023-04-2719:08:01+0800LV Status available#open0LV Size 152.00 MiBCurrent LE 38Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2--- Logical volume ---LV Path /dev/cl/swapLV Name swapVG Name clLV UUID fNUlBi-Vdj3-OcaE-Waaq-DsQy-eNb6-3zAUN4LV Write Access read/writeLV Creation host, time 192.168.2.22,2023-04-2118:57:34+0800LV Status available#open2LV Size 2.00 GiBCurrent LE 512Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:1--- Logical volume ---LV Path /dev/cl/rootLV Name rootVG Name clLV UUID LRAw0u-HJN0-jaZc-VSIJ-sVxe-G7F7-izx3yiLV Write Access read/writeLV Creation host, time 192.168.2.22,2023-04-2118:57:34+0800LV Status available#open1LV Size <17.00 GiBCurrent LE 4351Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:0
//在逻辑卷所挂载的目录中创建一个100MB的垃圾文件[root@centos ~]# dd if=/dev/zero of=/RAID2/files count=1 bs=100M
记录了1+0 的读入
记录了1+0 的写出
104857600bytes(105 MB,100 MiB) copied,4.80057 s,21.8 MB/s
//查看快照卷的状态[root@centos ~]# lvdisplay --- Logical volume ---LV Path /dev/storage/voLV Name voVG Name storageLV UUID 4VinRD-jJfs-s0Pe-Wva1-9kAX-QUAd-Vjq2MSLV Write Access read/writeLV Creation host, time centos,2023-04-2719:08:01+0800LV snapshot status source ofvo1 [active]LV Status available#open1LV Size 120.00 MiBCurrent LE 30Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2--- Logical volume ---LV Path /dev/storage/vo1LV Name vo1VG Name storageLV UUID tIHyhk-PenO-sSkN-Ew28-mbcl-zrYJ-pxjPYuLV Write Access read/writeLV Creation host, time centos,2023-04-2719:32:29+0800LV snapshot status active destination for voLV Status available#open0LV Size 120.00 MiBCurrent LE 30COW-table size 120.00 MiBCOW-table LE 30Allocated to snapshot 83.71%Snapshot chunk size 4.00 KiBSegments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:5--- Logical volume ---LV Path /dev/cl/swapLV Name swapVG Name clLV UUID fNUlBi-Vdj3-OcaE-Waaq-DsQy-eNb6-3zAUN4LV Write Access read/writeLV Creation host, time 192.168.2.22,2023-04-2118:57:34+0800LV Status available#open2LV Size 2.00 GiBCurrent LE 512Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:1--- Logical volume ---LV Path /dev/cl/rootLV Name rootVG Name clLV UUID LRAw0u-HJN0-jaZc-VSIJ-sVxe-G7F7-izx3yiLV Write Access read/writeLV Creation host, time 192.168.2.22,2023-04-2118:57:34+0800LV Status available#open1LV Size <17.00 GiBCurrent LE 4351Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:0
[root@centos ~]# lvremove /dev/storage/vo
Do you really want to remove active logical volume storage/vo?[y/n]: yLogical volume "vo" successfully removed.
(3)、删除卷组
[root@centos ~]# vgremove storage Volume group "storage" successfully removed
(4)、删除物理卷设备
[root@centos ~]# pvremove /dev/sdb /dev/sdcLabels on physical volume "/dev/sdb" successfully wiped.Labels on physical volume "/dev/sdc" successfully wiped.
[root@centos ~]# lvremove /dev/storage/vo
Do you really want to remove active logical volume storage/vo?[y/n]: yLogical volume "vo" successfully removed.
(3)、删除卷组
[root@centos ~]# vgremove storage Volume group "storage" successfully removed
(4)、删除物理卷设备
[root@centos ~]# pvremove /dev/sdb /dev/sdcLabels on physical volume "/dev/sdb" successfully wiped.Labels on physical volume "/dev/sdc" successfully wiped.