Linux运维之路


lvm扩容

admin 2019-11-08 25浏览 0条评论
首页/正文
分享到: / / / /
pvdisplay  查看磁盘属性信息,磁盘大小, 是否可分配等属性


#0. 添加磁盘后需要进行扫描识别

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan


#1. 检查当前磁盘
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/vda1                   20G  5.8G   13G  32% /
devtmpfs                    32G     0   32G   0% /dev
tmpfs                       32G     0   32G   0% /dev/shm
tmpfs                       32G  620K   32G   1% /run
tmpfs                       32G     0   32G   0% /sys/fs/cgroup
/dev/mapper/datavg-lv_opt  180G   96G   85G  54% /opt
tmpfs                      6.3G     0  6.3G   0% /run/user/1001
tmpfs                      6.3G     0  6.3G   0% /run/user/10000

注意: /dev/mapper/datavg-lv_opt 是逻辑卷的路径. 



#2. 检查新挂载的磁盘信息,  lvdisplay显示所有LVM逻辑卷空间大小、读写状态和快照信息等属性
[root@plat-ecloud01-andfleethe-prd-kafka03 ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/datavg/lv_opt
  LV Name                lv_opt
  VG Name                datavg
  LV UUID                hNZ0Jh-yFD5-trzO-0jdf-rT1U-QiaD-jXcTTH
  LV Write Access        read/write
  LV Creation host, time plat-ecloud02-andfleethe-uat-kafka03, 2018-10-10 09:53:43 +0800
  LV Status              available
  # open                 1
  LV Size                179.99 GiB
  Current LE             46077
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           252:0



#3. 查看可被分配的磁盘以及剩余Free PE配额
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# vgdisplay 
--- Logical volume 逻辑卷---
LV Path                /dev/vg_data/lv_data
LV Name                lv_data
VG Name                vg_data
LV UUID                CEKRcm-CDC9-Xg1U-0chG-Vs37-1yV3-UFoPMl
LV Write Access        read/write
LV Creation host, time xjdev-BIGDATATEST07, 2019-03-05 15:29:51 +0800
LV Status              available
# open                 0
LV Size                40.00 GiB       #----------#新磁盘,剩余40G
Current LE             10239
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     8192
Block device           252:1
 
--- Logical volume 逻辑卷---
LV Path                /dev/datavg/lv_opt
LV Name                lv_opt
VG Name                datavg
LV UUID                lcglRQ-UETa-MykQ-IRPh-Px7t-ePnZ-mGnsJ9
LV Write Access        read/write
LV Creation host, time plat-ecloud02-andfleethe-uat-kafka02, 2018-10-10 09:53:44 +0800
LV Status              available
# open                 1
LV Size                179.99 GiB
Current LE             46077
Segments               3
Allocation             inherit
Read ahead sectors     auto
- currently set to     8192
Block device           252:0
------------------------------------------------------------

移除卷:
lvremove /dev/vg_data/lv_data 移除这个卷
Do you really want to remove active logical volume vg_data/lv_data? [y/n]: y


直接看这个就行了
配置:

lvdisplay  显示逻辑卷属性:
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# lvdisplay
 --- Logical volume ---
 LV Path                /dev/datavg/lv_opt    #需要将新磁盘扩容到这里
 LV Name                lv_opt
 VG Name                datavg
 LV UUID                lcglRQ-UETa-MykQ-IRPh-Px7t-ePnZ-mGnsJ9
 LV Write Access        read/write
 LV Creation host, time plat-ecloud02-andfleethe-uat-kafka02, 2018-10-10 09:53:44 +0800
 LV Status              available
 # open                 1
 LV Size                179.99 GiB
 Current LE             46077
 Segments               3
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     8192
 Block device           252:0


设置为可扩展卷[40G] 将/dev/vde新磁盘加入到datavg卷组管理,通过fdisk -l可以看到这个盘是个新加的盘,他是/dev/vde:

vgextend datavg /dev/vde

[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# fdisk -l

Disk /dev/vde: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes




加入到datavg卷组管理后通过vgdisplay查看是否加入到卷组:
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# vgdisplay 
  --- Volume group ---
  VG Name               datavg
  System ID             
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               219.98 GiB
  PE Size               4.00 MiB
  Total PE              56316
  Alloc PE / Size       46077 / 179.99 GiB
  Free  PE / Size       10239 / 40.00 GiB    <---这就是,当容量被使用后,这理会减少,直到0
  VG UUID               DyqhbJ-uq4J-leOE-WAXy-FIhQ-ZhHN-xATEvC

加入到卷组后就可以为需要扩容的磁盘进行扩容操作
为/dev/datavg/lv_opt扩容:
lvextend -l +39G /dev/datavg/lv_opt


扩容后通过vgdisplay 查看,还剩余1020.00 MiB:

[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# vgdisplay 
  --- Volume group ---
  VG Name               datavg
  System ID             
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               219.98 GiB
  PE Size               4.00 MiB
  Total PE              56316
  Alloc PE / Size       56061 / 218.99 GiB
  Free  PE / Size       255 / 1020.00 MiB   #------还剩余1020.00 MiB
  VG UUID               DyqhbJ-uq4J-leOE-WAXy-FIhQ-ZhHN-xATEvC
 


再次扩容:
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# lvextend -L +1020M /dev/datavg/lv_opt
  Size of logical volume datavg/lv_opt changed from 218.99 GiB (56061 extents) to 219.98 GiB (56316 extents).
  Logical volume datavg/lv_opt successfully resized.



再次检查:
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# vgdisplay 
  --- Volume group ---
  VG Name               datavg
  System ID             
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               219.98 GiB
  PE Size               4.00 MiB
  Total PE              56316
  Alloc PE / Size       56316 / 219.98 GiB
  Free  PE / Size       0 / 0       #-----------剩余0 分配完毕.
  VG UUID               DyqhbJ-uq4J-leOE-WAXy-FIhQ-ZhHN-xATEvC
	
	
##再次查看磁盘是否扩容:
	
[root@plat-ecloud01-andfleethe-prd-kafka02 ~]# df -h
  Filesystem                 Size  Used Avail Use% Mounted on
  /dev/vda1                   20G  5.8G   13G  32% /
  devtmpfs                    32G     0   32G   0% /dev
  tmpfs                       32G     0   32G   0% /dev/shm
  tmpfs                       32G  616K   32G   1% /run
  tmpfs                       32G     0   32G   0% /sys/fs/cgroup
  /dev/mapper/datavg-lv_opt  220G   97G  124G  44% /opt
  tmpfs                      6.3G     0  6.3G   0% /run/user/1001
  tmpfs                      6.3G     0  6.3G   0% /run/user/10000
  
最后修改:2019-11-08 22:58:23 © 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

上一篇

发表评论

评论列表

还没有人评论哦~赶快抢占沙发吧~