[linux] LVM原磁盘扩容(非增加磁盘)

[linux] LVM原磁盘扩容(非增加磁盘),第1张

概述阿里云机器,ECS运行时磁盘由300G扩容到500,重启机器生效后登录。可以看到/data目录总大小300G,/dev/vdb已经扩容到500G。 [[email protected] ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/vda1 40G

阿里云机器,ECS运行时磁盘由300G扩容到500,重启机器生效后登录。可以看到/data目录总大小300G,/dev/vdb已经扩容到500G。

[[email protected] ~]# df -hfilesystem                   Size  Used Avail Use% Mounted on/dev/vda1                     40G  5.6G   32G  15% /devtmpfs                     3.9G     0  3.9G   0% /devtmpfs                        3.9G   12K  3.9G   1% /dev/shmtmpfs                        3.9G  380K  3.9G   1% /runtmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup/dev/mapper/vg_data-lv_data  300G  218G   83G  73% /datatmpfs                        783M     0  783M   0% /run/user/1000[[email protected]-elasticsearch2 ~]# fdisk -ldisk /dev/vda: 42.9 GB,42949672960 bytes,83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesdisk label type: dosdisk IDentifIEr: 0x0008d73a   Device Boot      Start         End      Blocks   ID  System/dev/vda1   *        2048    83884031    41940992   83  linuxdisk /dev/vdb: 536.9 GB,536870912000 bytes,1048576000 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesdisk /dev/mapper/vg_data-lv_data: 322.1 GB,322118352896 bytes,629137408 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes

1.pvs先查看已有的pv,再resize

[[email protected] ~]# pvs  PV         VG      Fmt  Attr PSize    PFree  /dev/vdb   vg_data lvm2 a--  <300.00g    0 [[email protected]-elasticsearch2 ~]# pvresize /dev/vdb  Physical volume "/dev/vdb" changed  1 physical volume(s) resized / 0 physical volume(s) not resized[[email protected]-elasticsearch2 ~]# pvs  PV         VG      Fmt  Attr PSize    PFree    /dev/vdb   vg_data lvm2 a--  <500.00g 200.00g

2.vg大小随pvresize而变

vgs原大小应该在pvresize之前才能看到[[email protected]-elasticsearch2 ~]# vgs  VG      #PV #LV #SN Attr   VSize    VFree  vg_data   1   1   0 wz--n- <300.00g    0pvresize后vg自动扩容了[[email protected]-elasticsearch2 ~]# vgs  VG      #PV #LV #SN Attr   VSize    VFree    vg_data   1   1   0 wz--n- <500.00g 200.00g

3.查看要扩容的lv,开始扩容

[[email protected] ~]# lvdisplay   --- Logical volume ---  LV Path                /dev/vg_data/lv_data  LV name                lv_data  VG name                vg_data  LV UUID                4Ncz4O-016I-Vh8u-vmOT-BZ7W-ARiy-fCHO4s  LV Write Access        read/write  LV Creation host,time HD1g-elk-elastic2,2018-09-06 14:34:31 +0800  LV Status              available  # open                 1  LV Size                <300.00 GiB  Current LE             76799  Segments               1  Allocation             inherit  Read ahead sectors     auto  - currently set to     8192  Block device           252:0   [[email protected]-elasticsearch2 ~]# lvextend -l +100%FREE /dev/vg_data/lv_data  Size of logical volume vg_data/lv_data changed from <300.00 GiB (76799 extents) to <500.00 GiB (127999 extents).  Logical volume vg_data/lv_data successfully resized.[[email protected]-elasticsearch2 ~]# lvs  LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log cpy%Sync Convert  lv_data vg_data -wi-ao---- <500.00g

4.查看原挂载节点文件系统格式,选用命令resize挂载点大小,xfs文件系统用xfs_growfs,ext*文件系统用resize2fs

[[email protected] ~]# df -hTfilesystem                  Type      Size  Used Avail Use% Mounted on/dev/vda1                   ext4       40G  5.6G   32G  15% /devtmpfs                    devtmpfs  3.9G     0  3.9G   0% /devtmpfs                       tmpfs     3.9G   12K  3.9G   1% /dev/shmtmpfs                       tmpfs     3.9G  380K  3.9G   1% /runtmpfs                       tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup/dev/mapper/vg_data-lv_data xfs       300G  218G   83G  73% /datatmpfs                       tmpfs     783M     0  783M   0% /run/user/1000[[email protected]-elasticsearch2 ~]# xfs_growfs /dev/vg_data/lv_dataMeta-data=/dev/mapper/vg_data-lv_data isize=512    agcount=7,agsize=13106944 blks         =                       sectsz=512   attr=2,projID32bit=1         =                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=78642176,imaxpct=25         =                       sunit=0      swIDth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=25599,version=2         =                       sectsz=512   sunit=0 blks,lazy-count=1realtime =none                   extsz=4096   blocks=0,rtextents=0data blocks changed from 78642176 to 131070976[[email protected]-elasticsearch2 ~]# df -hfilesystem                   Size  Used Avail Use% Mounted on/dev/vda1                     40G  5.6G   32G  15% /devtmpfs                     3.9G     0  3.9G   0% /devtmpfs                        3.9G   12K  3.9G   1% /dev/shmtmpfs                        3.9G  380K  3.9G   1% /runtmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup/dev/mapper/vg_data-lv_data  500G  218G  283G  44% /datatmpfs                        783M     0  783M   0% /run/user/1000
总结

以上是内存溢出为你收集整理的[linux] LVM原磁盘扩容(非增加磁盘)全部内容,希望文章能够帮你解决[linux] LVM原磁盘扩容(非增加磁盘)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1029394.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存