当前位置: 首页 > news >正文

Linux 逻辑卷管理

Linux 逻辑卷管理

文章目录

  • Linux 逻辑卷管理
    • 创建物理卷 卷组 逻辑卷
    • 扩展和缩减卷组
    • 扩展和缩减逻辑卷
    • 扩展 XFS 文件系统
    • 扩展 EXT4 文件系统
    • 缩减 EXT4 文件系统
    • 逻辑卷快照
    • raid 逻辑卷
    • 小总结
  • 删除丢失的物理卷
  • 扩容回来
  • 修复raid1 逻辑卷
  • 扫描物理卷变化

创建物理卷 卷组 逻辑卷

#创建物理卷[root@server ~ 13:29:56]# pvcreate /dev/sdbPhysical volume "/dev/sdb" successfully created.[root@server ~ 13:35:48]# pvcreate /dev/sd{c,d}Physical volume "/dev/sdc" successfully created.Physical volume "/dev/sdd" successfully created.[root@server ~ 13:36:04]# pvsPV         VG     Fmt  Attr PSize    PFree /dev/sda2  centos lvm2 a--  <199.00g  4.00m/dev/sdb          lvm2 ---    20.00g 20.00g/dev/sdc          lvm2 ---    20.00g 20.00g/dev/sdd          lvm2 ---    20.00g 20.00g#创建卷组[root@server ~ 13:36:10]# vgcreate webapp /dev/sdbVolume group "webapp" successfully created
[root@server ~ 13:36:43]# vgcreate dbapp /dev/sd{c,d}Volume group "dbapp" successfully created[root@server ~ 13:37:11]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <20.00g/dev/sdc   dbapp  lvm2 a--   <20.00g <20.00g/dev/sdd   dbapp  lvm2 a--   <20.00g <20.00g[root@server ~ 13:37:13]# vgsVG     #PV #LV #SN Attr   VSize    VFree  centos   1   3   0 wz--n- <199.00g   4.00mdbapp    2   0   0 wz--n-   39.99g  39.99gwebapp   1   0   0 wz--n-  <20.00g <20.00g#创建逻辑卷[root@server ~ 13:37:21]# lvcreate -n webapp01 -L 5G webappLogical volume "webapp01" created.[root@server ~ 13:38:19]# lvcreate -n data01 -L 25G dbappLogical volume "data01" created.[root@server ~ 13:38:33]# lvsLV       VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome     centos -wi-ao---- <145.12g                                                    root     centos -wi-ao----   50.00g                                                    swap     centos -wi-ao----   <3.88g                                                    data01   dbapp  -wi-a-----   25.00g                                                    webapp01 webapp -wi-a-----    5.00g                                                    
[root@server ~ 13:38:37]# ls -l /dev/dbapp/data01 /dev/mapper/dbapp-data01lrwxrwxrwx 1 root root 7 Nov 14 13:38 /dev/dbapp/data01 -> ../dm-4
lrwxrwxrwx 1 root root 7 Nov 14 13:38 /dev/mapper/dbapp-data01 -> ../dm-4[root@server ~ 13:38:57]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <15.00g/dev/sdc   dbapp  lvm2 a--   <20.00g      0 /dev/sdd   dbapp  lvm2 a--   <20.00g  14.99g[root@server ~ 13:39:11]# lsblk /dev/sd{b..d}
NAME              MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb                 8:16   0  20G  0 disk 
└─webapp-webapp01 253:3    0   5G  0 lvm  
sdc                 8:32   0  20G  0 disk 
└─dbapp-data01    253:4    0  25G  0 lvm  
sdd                 8:48   0  20G  0 disk 
└─dbapp-data01    253:4    0  25G  0 lvm  [root@server ~ 13:39:35]# mkfs.xfs /dev/webapp/webapp01 
meta-data=/dev/webapp/webapp01   isize=512    agcount=4, agsize=327680 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=1310720, 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@server ~ 13:41:03]# mkdir -p /webapp/webapp01[root@server ~ 13:41:24]# mount /dev/webapp/webapp01 /webapp/webapp01[root@server ~ 13:41:37]# df -h /webapp/webapp01
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01  5.0G   33M  5.0G   1% /webapp/webapp01[root@server ~ 13:41:45]# lsblk /dev/sd{b..d}
NAME              MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb                 8:16   0  20G  0 disk 
└─webapp-webapp01 253:3    0   5G  0 lvm  /webapp/webapp01
sdc                 8:32   0  20G  0 disk 
└─dbapp-data01    253:4    0  25G  0 lvm  
sdd                 8:48   0  20G  0 disk 
└─dbapp-data01    253:4    0  25G  0 lvm  [root@server ~ 13:42:18]# cp /etc/ho* /webapp/webapp01[root@server ~ 13:42:44]# ls /webapp/webapp01
host.conf  hostname  hosts  hosts.allow  hosts.deny
#清理[root@server ~ 13:42:50]# umount /webapp/webapp01
[root@server ~ 13:52:08]# lvremove /dev/webapp/webapp01 /dev/dbapp/data01
Do you really want to remove active logical volume webapp/webapp01? [y/n]: yLogical volume "webapp01" successfully removed
Do you really want to remove active logical volume dbapp/data01? [y/n]: yLogical volume "data01" successfully removed
[root@server ~ 13:52:23]# vgremove webapp dbappVolume group "webapp" successfully removedVolume group "dbapp" successfully removed[root@server ~ 13:52:29]# pvremove /dev/sd{b..d}Labels on physical volume "/dev/sdb" successfully wiped.Labels on physical volume "/dev/sdc" successfully wiped.Labels on physical volume "/dev/sdd" successfully wiped.[root@server ~ 13:52:34]# lsblk 
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   200G  0 disk 
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0   199G  0 part ├─centos-root 253:0    0    50G  0 lvm  /├─centos-swap 253:1    0   3.9G  0 lvm  [SWAP]└─centos-home 253:2    0 145.1G  0 lvm  /home
sdb               8:16   0    20G  0 disk 
sdc               8:32   0    20G  0 disk 
sdd               8:48   0    20G  0 disk 
sde               8:64   0    20G  0 disk 
sdf               8:80   0    20G  0 disk 
sdg               8:96   0    20G  0 disk 
sr0              11:0    1   4.4G  0 rom  [root@server ~ 13:52:39]# pvsPV         VG     Fmt  Attr PSize    PFree/dev/sda2  centos lvm2 a--  <199.00g 4.00m
#pccreate后直接清除,但是不彻底,故不推荐[root@server ~ 13:52:51]#wipefs -a /dev/sd{b..d}#查看
[root@server ~ 13:53:20]# wipefs /dev/sd{b..d}

扩展和缩减卷组

#扩展和缩减卷组[root@server ~ 13:53:40]# vgcreate webapp /dev/sdbPhysical volume "/dev/sdb" successfully created.Volume group "webapp" successfully created[root@server ~ 14:09:24]# lvcreate -n webapp01 -L 10G webapp
WARNING: xfs signature detected on /dev/webapp/webapp01 at offset 0. Wipe it? [y/n]: yWiping xfs signature on /dev/webapp/webapp01.Logical volume "webapp01" created.[root@server ~ 14:09:41]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <10.00g[root@server ~ 14:09:53]# vgextend webapp /dev/sd{c,d}Physical volume "/dev/sdc" successfully created.Physical volume "/dev/sdd" successfully created.Volume group "webapp" successfully extended[root@server ~ 14:10:07]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <10.00g/dev/sdc   webapp lvm2 a--   <20.00g <20.00g/dev/sdd   webapp lvm2 a--   <20.00g <20.00g[root@server ~ 14:10:11]# lvsLV       VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome     centos -wi-ao---- <145.12g                                                    root     centos -wi-ao----   50.00g                                                    swap     centos -wi-ao----   <3.88g                                                    webapp01 webapp -wi-a-----   10.00g                                                    
[root@server ~ 14:10:17]# vgsVG     #PV #LV #SN Attr   VSize    VFree  centos   1   3   0 wz--n- <199.00g   4.00mwebapp   3   1   0 wz--n-  <59.99g <49.99g
[root@server ~ 14:10:34]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <10.00g/dev/sdc   webapp lvm2 a--   <20.00g <20.00g/dev/sdd   webapp lvm2 a--   <20.00g <20.00g[root@server ~ 14:10:51]# vgreduce webapp /dev/sdbPhysical volume "/dev/sdb" still in use[root@server ~ 14:11:12]# pvremove /dev/sdb /dev/sddPV /dev/sdb is used by VG webapp so please use vgreduce first.(If you are certain you need pvremove, then confirm by using --force twice.)/dev/sdb: physical volume label not removed.PV /dev/sdd is used by VG webapp so please use vgreduce first.(If you are certain you need pvremove, then confirm by using --force twice.)/dev/sdd: physical volume label not removed.[root@server ~ 14:11:42]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <10.00g/dev/sdc   webapp lvm2 a--   <20.00g <20.00g/dev/sdd   webapp lvm2 a--   <20.00g <20.00g
[root@server ~ 14:11:48]# pvmove /dev/sdb /dev/sdd/dev/sdb: Moved: 0.27%/dev/sdb: Moved: 100.00%[root@server ~ 14:12:48]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb   webapp lvm2 a--   <20.00g <20.00g/dev/sdc   webapp lvm2 a--   <20.00g <20.00g/dev/sdd   webapp lvm2 a--   <20.00g <10.00g
[root@server ~ 14:12:53]# vgreduce webapp /dev/sdbRemoved "/dev/sdb" from volume group "webapp"[root@server ~ 14:13:05]# pvsPV         VG     Fmt  Attr PSize    PFree  /dev/sda2  centos lvm2 a--  <199.00g   4.00m/dev/sdb          lvm2 ---    20.00g  20.00g/dev/sdc   webapp lvm2 a--   <20.00g <20.00g/dev/sdd   webapp lvm2 a--   <20.00g <10.00g

扩展和缩减逻辑卷

#扩展和缩减逻辑卷[root@server ~ 14:13:07]# lvextend -L +2G /dev/webapp/webapp01Size of logical volume webapp/webapp01 changed from 10.00 GiB (2560 extents) to 12.00 GiB (3072 extents).Logical volume webapp/webapp01 successfully resized.[root@server ~ 14:13:32]# lvsLV       VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Converthome     centos -wi-ao---- <145.12g                                                    root     centos -wi-ao----   50.00g                                                    swap     centos -wi-ao----   <3.88g                                                    webapp01 webapp -wi-a-----   12.00g                                                    
[root@server ~ 14:13:35]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-a----- 12.00g                                                    
[root@server ~ 14:13:42]# lvreduce -L -2G /dev/webapp/webapp01WARNING: Reducing active logical volume to 10.00 GiB.THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce webapp/webapp01? [y/n]: ySize of logical volume webapp/webapp01 changed from 12.00 GiB (3072 extents) to 10.00 GiB (2560 extents).Logical volume webapp/webapp01 successfully resized.[root@server ~ 14:13:53]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-a----- 10.00g      

扩展 XFS 文件系统

#XFS文件系统只支持扩展,不支持缩减[root@server ~ 14:14:06]# mkfs.xfs /dev/webapp/webapp01
meta-data=/dev/webapp/webapp01   isize=512    agcount=4, agsize=655360 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=2621440, 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@server ~ 14:50:10]# mkdir -p /var/www/html[root@server ~ 14:50:15]# mount /dev/webapp/webapp01 /var/www/html[root@server ~ 14:50:24]# cp /etc/host* /var/www/html[root@server ~ 14:50:30]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01   10G   33M   10G   1% /var/www/html[root@server ~ 14:50:47]# ls /var/www/html
host.conf  hostname  hosts  hosts.allow  hosts.deny[root@server ~ 14:50:54]# #lvextend -L 30G /dev/webapp/webapp01[root@server ~ 14:51:50]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-ao---- 10.00g                                                    
[root@server ~ 14:51:56]# lvextend -L 15G /dev/webapp/webapp01Size of logical volume webapp/webapp01 changed from 10.00 GiB (2560 extents) to 15.00 GiB (3840 extents).Logical volume webapp/webapp01 successfully resized.
[root@server ~ 14:52:17]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-ao---- 15.00g                                                    
[root@server ~ 14:52:21]# xfs_growfs /var/www/html
meta-data=/dev/mapper/webapp-webapp01 isize=512    agcount=4, agsize=655360 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2621440 to 3932160[root@server ~ 14:52:30]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01   15G   33M   15G   1% /var/www/html[root@server ~ 14:52:35]# ls /var/www/html
host.conf  hostname  hosts  hosts.allow  hosts.deny[root@server ~ 14:52:52]# lvextend -rL 20G /dev/webapp/webapp01Size of logical volume webapp/webapp01 changed from 15.00 GiB (3840 extents) to 20.00 GiB (5120 extents).Logical volume webapp/webapp01 successfully resized.
meta-data=/dev/mapper/webapp-webapp01 isize=512    agcount=6, agsize=655360 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 3932160 to 5242880[root@server ~ 14:53:00]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-ao---- 20.00g                                                    
[root@server ~ 14:53:08]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01   20G   33M   20G   1% /var/www/html

扩展 EXT4 文件系统

#EXT4文件系统即支持扩展,也支持缩减#扩展 EXT4 [root@server ~ 14:54:04]# umount /var/www/html[root@server ~ 14:54:17]# mkfs.ext4 /dev/webapp/webapp01
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   [root@server ~ 14:54:25]# mount /dev/webapp/webapp01 /var/www/html[root@server ~ 14:54:30]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01   20G   45M   19G   1% /var/www/html[root@server ~ 14:54:35]# cp /etc/host* /var/www/html
[root@server ~ 14:54:53]# ls /var/www/html
host.conf  hostname  hosts  hosts.allow  hosts.deny  lost+found[root@server ~ 14:54:57]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-ao---- 20.00g                                                    
[root@server ~ 14:55:09]# lvextend -L 25G /dev/webapp/webapp01 Size of logical volume webapp/webapp01 changed from 20.00 GiB (5120 extents) to 25.00 GiB (6400 extents).Logical volume webapp/webapp01 successfully resized.[root@server ~ 14:55:36]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-ao---- 25.00g                                                    
[root@server ~ 14:55:39]# resize2fs /dev/webapp/webapp01
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/webapp/webapp01 is mounted on /var/www/html; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 4
The filesystem on /dev/webapp/webapp01 is now 6553600 blocks long.[root@server ~ 14:55:49]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01   25G   44M   24G   1% /var/www/html[root@server ~ 14:55:57]# ls /var/www/html
host.conf  hostname  hosts  hosts.allow  hosts.deny  lost+found[root@server ~ 14:56:31]# lvextend -rL 30G /dev/webapp/webapp01Size of logical volume webapp/webapp01 changed from 25.00 GiB (6400 extents) to 30.00 GiB (7680 extents).Logical volume webapp/webapp01 successfully resized.
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/webapp-webapp01 is mounted on /var/www/html; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 4
The filesystem on /dev/mapper/webapp-webapp01 is now 7864320 blocks long.[root@server ~ 14:56:38]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-ao---- 30.00g                                                    
[root@server ~ 14:56:44]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01   30G   44M   28G   1% /var/www/html

缩减 EXT4 文件系统

#缩减 EXT4 #卸载文件系统[root@server ~ 14:56:49]# umount /var/www/html[root@server ~ 14:57:59]# resize2fs /dev/webapp/webapp01 10G
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/webapp/webapp01' first.#e2fsck 文件系统[root@server ~ 14:58:17]# e2fsck -f /dev/webapp/webapp01
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/webapp/webapp01: 16/1966080 files (0.0% non-contiguous), 167447/7864320 blocks#缩减文件系统[root@server ~ 14:58:23]# resize2fs /dev/webapp/webapp01 10G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/webapp/webapp01 to 2621440 (4k) blocks.
The filesystem on /dev/webapp/webapp01 is now 2621440 blocks long.[root@server ~ 14:58:27]# df -h /var/www/html
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G  1.6G   49G   4% /
[root@server ~ 14:58:40]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-a----- 30.00g                                                 
#缩减lv[root@server ~ 14:59:01]# lvreduce -L 10G /dev/webapp/webapp01WARNING: Reducing active logical volume to 10.00 GiB.THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce webapp/webapp01? [y/n]: ySize of logical volume webapp/webapp01 changed from 30.00 GiB (7680 extents) to 10.00 GiB (2560 extents).Logical volume webapp/webapp01 successfully resized.
[root@server ~ 14:59:08]# lvs /dev/webapp/webapp01LV       VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertwebapp01 webapp -wi-a----- 10.00g                                                    
#挂载测试[root@server ~ 14:59:10]# mount /dev/webapp/webapp01 /var/www/html
[root@server ~ 14:59:15]# df -h /var/www/html
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/webapp-webapp01  9.8G   37M  9.2G   1% /var/www/html
[root@server ~ 14:59:22]# ls /var/www/html
host.conf  hostname  hosts  hosts.allow  hosts.deny  lost+found

逻辑卷快照

# 创建快照:快照的容量不能小于lv容量
lvcreate -s -n webapp01-snap1 -L 10G /dev/webapp/webapp01# 挂载快照
mount /dev/webapp/webapp01-snap1 /webapp/webapp01/# 查看数据
ls /webapp/webapp01/

raid 逻辑卷

#准备环境umount /webapp/webapp0
umount /var/www/html
lvremove /dev/webapp/webapp01*#创建 raid1 逻辑卷lvcreate --type raid1 -n webapp01 -L 15G webappmkfs.xfs /dev/webapp/webapp01mount /dev/webapp/webapp01 /var/www/html/cp /etc/ho* /var/www/html/#模拟故障dd if=/dev/zero of=/dev/sdd bs=1M count=256#此时文件系统仍可以正方访问ls /var/www/html/umount /var/www/htmlmount /dev/webapp/webapp01 /var/www/html/#修复raid# 删除丢失的物理卷
vgreduce --removemissing webapp --force# 扩容回来
vgextend webapp /dev/sdd# 修复raid1 逻辑卷
lvconvert --repair /dev/webapp/webapp01# 扫描物理卷变化
pvscan#验证
pvs|grep webap

小总结

硬盘管理:

  1. 磁盘分区
    单个盘空间太大,大分小
    缺点:分区的空间大小不好调整。
  2. raid
    文件系统需要的空间超过单个硬盘。
    缺点:分区的空间大小不好调整。
  3. LVM logical volume manage
    除了支持以上存储管理有点,还支持更多的有点,例如快照功能。

两种类型的区别:

  • raid,由多个硬盘组成磁盘组 disk array,raid可以继续分割为分区使用,
  • lvm, 由多个硬盘(phycical volume)组成卷组(volume group),vg可以继续分割为lv(logical volume)使用
    tml/

umount /var/www/html

mount /dev/webapp/webapp01 /var/www/html/

#修复raid

删除丢失的物理卷

vgreduce --removemissing webapp --force

扩容回来

vgextend webapp /dev/sdd

修复raid1 逻辑卷

lvconvert --repair /dev/webapp/webapp01

扫描物理卷变化

pvscan

#验证
pvs|grep webap

## 小总结硬盘管理:
1. 磁盘分区单个盘空间太大,大分小缺点:分区的空间大小不好调整。
2. raid文件系统需要的空间超过单个硬盘。缺点:分区的空间大小不好调整。
3. LVM logical volume manage除了支持以上存储管理有点,还支持更多的有点,例如快照功能。两种类型的区别:- raid,由多个硬盘组成磁盘组 disk array,raid可以继续分割为分区使用,
- lvm, 由多个硬盘(phycical volume)组成卷组(volume group),vg可以继续分割为lv(logical volume)使用
http://www.dtcms.com/a/609455.html

相关文章:

  • FFmpeg原始帧处理-滤镜设置视频宽高比
  • 【Python办公】处理 CSV和Excel 文件操作指南
  • Unity Shader Graph 3D 实例 - 一个简单的3D打印效果
  • ReAct 框架实现(基于langgraph)
  • 流媒体,包含哪些技术?Zynq MP方案
  • 网站支持ipv6做哪些改造app公司网站模板
  • 怎么做刷东西的网站网址免费全自动推广平台
  • 校园墙|校园社区|基于Java+vue的校园墙小程序系统(源码+数据库+文档)
  • Linux/宝塔上没有ssl证书的站点使用https访问会跳转的其他有ssl证书网站
  • Centos环境中Django项目中gunicorn的配置和使用
  • LangGraph系列:多智能体终极方案,ReAct+MCP工业级供应链系统
  • 移动端 HTTPS 抓包实战,多工具组合分析与高效排查指南
  • 自动化测试工具Parasoft C/C++test如何导入IAR项目
  • 蓝桥杯嵌入式赛道—-软件篇(GPIO输出模式配置)
  • 仿第四城地方门户网站模板python可以做网站吗
  • ToDesk如何充当分屏显示器?扩展屏、多屏结合虚拟屏都可行!
  • qKnow 知识平台开源版 v1.0.3 发布:Docker Compose 部署 多项稳定性优化和关键问题修复
  • 【Prompt学习技能树地图】检索增强生成(RAG)核心技术剖析与实践指南
  • Zookeeper在Kafka中的作用
  • MySQL数据表操作
  • 访问外国网站速度慢怎样优化标题关键词
  • 《VScode搭建教程(附安装包)--- 开启你的编程之旅》
  • MFC Edit Control控件完全指南:从基础使用到高级定制
  • C语言编译器安装教程 | 快速上手C语言编译环境的配置与调试
  • C库OpenSSL安装与VisualStudio配置
  • ppt模板免费下载网站不需要登录网页设计的三大基本技术
  • 什么是营销型网站?h5可以连接别的网站吗
  • Android13修改系统支持gps同步时间
  • Webpack到Vite:构建工具迁移实战经验总结
  • QT音乐播放器18----新歌速递播放、隐藏顶部和底部工具栏、自定义ToolTips