0 0 8 49 0 active sync /dev/sdd1
1 1 8 65 1 active sync /dev/sde1
2 2 8 81 2 active sync /dev/sdf1
[root@dns ~]# mdadm -A --uuid=3c416add:9fa78bcf:9b9e60ef:5f5de4da /dev/md1
mdadm: /dev/md1 has been started with 3 drives.
--------------------------------------------------------
模拟raid中其中一块盘故障
[root@dns ~]# mdadm /dev/md1 --fail /dev/sdd1
mdadm: set /dev/sdd1 faulty in /dev/md1
[root@dns ~]# cat /proc/mdstat
Personalities : [raid0] [raid6] [raid5] [raid4]
md1 : active raid5 sdd1[3](F) sdf1[2] sde1[1] --可以看到sdd1后面有F标记
2088192 blocks level 5, 64k chunk, algorithm 2 [3/2] [_UU]
[root@dns ~]# mdadm /dev/md1 --remove /dev/sdd1
mdadm: hot removed /dev/sdd1
[root@dns ~]# mdadm /dev/md1 --add /dev/sdg1
mdadm: added /dev/sdg1
--换了一块盘,此时也可以watch cat /proc/mdstat 去查看数据同步的状态,完成后,可以看到原来的数据还在
--------------------------------------------------------
删除掉raid设备
1,umount
2,[root@dns ~]# mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
mdadm: hot remove failed for /dev/sdb1: Device or resource busy
[root@dns ~]# mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1
mdadm: set /dev/sdc1 faulty in /dev/md0
mdadm: hot remove failed for /dev/sdc1: Device or resource busy
3,mdadm --stop /dev/md0
4,
直接用fdisk删除分区
或者
用下面命令擦除superblock
[root@dns ~]# mdadm --misc --zero-superblock /dev/sdb1
[root@dns ~]# mdadm --misc --zero-superblock /dev/sdc1
----------------------------------------------------------------------
lvm logical volumn manager 逻辑卷管理
可以自由增大或者缩小卷空间的大小
pv physical volumn(物理卷) 把实际分区设备划为pv , pv是lvm物理标记
vg volumn group (卷组) 把pv划分成vg,相当于组合成lvm能够使用一个大硬盘
pe physical extend (物理扩展)vg组成的最小单位,默认是4M,vg最大支持65535个pe,相当于是block
lv logical volumn (逻辑卷) 实际可以使用的lvm的设备,相当是把vg划分成可用的分区
1,划分pv
创建pv使用pvcreate命令
[root@dns ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@dns ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@dns ~]# pvcreate /dev/md1
Physical volume "/dev/md1" successfully created
查看相关信息的命令 pvscan pvdisplay
删除pv的命令 pvremove /dev/sdb1
2,划分vg
[root@dns ~]# vgcreate li /dev/md1 --创建一个叫li的vg,把/dev/md1加进去
Volume group "li" successfully created
[root@dns ~]# vgextend li /dev/sdb1 --再入li这个vg增加pv,要用vgextend
Volume group "li" successfully extended
[root@dns ~]# vgextend li /dev/sdc1
Volume group "li" successfully extended
查看相关信息的命令vgscan vgdisplay
[root@dns ~]# vgreduce li /dev/sdc1 --vgreduce跟vgextend是相反的,是在vg里移除pv
Removed "/dev/sdc1" from volume group "li"
移除vg的命令是vgremove,它是和vgcreate相反
3,创建lv
[root@dns ~]# lvcreate -L 500m -n li01 li --在li这个vg里划分出一个叫li01的lv,大小为500m
Logical volume "li01" created
[root@dns ~]# lvcreate -L 500M -n li02 li
Logical volume "li02" created
[root@dns ~]# lvcreate -l 125 -n li03 li -- 小写l参数指定的是pe的个数,这里4M*125=500m
Logical volume "li03" created
[root@dns ~]# lvcreate -L 1g -n aa01 aa
Logical volume "aa01" created
查看的相关参数为lvscan lvdisplay
[root@dns ~]# lvscan --创建后,可以看到这些实际可用的lv存放在/dev/vg名/lv名
ACTIVE '/dev/aa/aa01' [1.00 GB] inherit
ACTIVE '/dev/li/li01' [500.00 MB] inherit
ACTIVE '/dev/li/li02' [500.00 MB] inherit
ACTIVE '/dev/li/li03' [500.00 MB] inherit
[root@dns ~]# mkfs.ext3 /dev/aa/aa01 --格式化lv后就可以挂载使用
移除lv使用lvremove
完全删除lvm,就要先lvremove,再vgremove,最后pvremove
--------------------------------
lv的扩容
1,先考虑vg是否还有空间去扩容,如果没有,那么要先扩容vg,使用vgextend
2,扩lv
[root@dns ~]# lvextend -L 1.5g /dev/aa/aa01 --把/dev/aa/aa01的lv扩成1.5g
Extending logical volume aa01 to 1.50 GB
Logical volume aa01 successfully resized
[root@dns ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/aa-aa01 1008M 34M 924M 4% /mnt --查看已经挂载的大小,没有变化