所有存储卷配置为 LVM 设备。可以提供底层虚拟化技术以支持联机磁盘扩展,从而联机调整这些卷的大小。在虚拟机引导时,将通过 cloud-init 自动扩展磁盘。

要在引导后扩展磁盘,请执行以下操作:

  1. 登录到 SASE Orchestrator 系统控制台。
  2. 确定支持数据库卷的物理磁盘。
    vgs -o +devices store

    示例:

    root@vco:~# vgs -o +devices db_data
       \  VG      #PV #LV #SN Attr   VSize   VFree   Devices
         store   1   1   0 wz--n- 500.00g 125.00g /dev/sdb(0)
  3. 识别物理磁盘连接。
    lshw -class volume
    示例:
    /dev/sdb is attached to scsi@2:0.1.0 (Host: scsi2 Channel: 00 Id: 01 Lun: 00)
    root@vco:~# lshw -class volume
      *-volume
           description: EXT4 volume
           vendor: Linux
           physical id: 1
           bus info: scsi@2:0.0.0,1
           logical name: /dev/sda1
           logical name: /
           version: 1.0
           serial: 9d212247-77c4-4f98-a5c2-7f8470fa2da8
           size: 10239MiB
           capacity: 10239MiB
           capabilities: primary bootable journaled extended_attributes large_files huge_files dir_nlink recover extents ext4 ext2 initialized 
           configuration: created=2016-02-22 20:49:38 filesystem=ext4 label=cloudimg-rootfs lastmountpoint=/ modified=2016-02-22 21:18:58 mount.fstype=ext4 mount.options=rw,relatime,data=ordered mounted=2016-10-06 23:22:04 state=mounted 
      *-disk:1
           description: SCSI Disk
           physical id: 0.1.0
           bus info: scsi@2:0.1.0
           logical name: /dev/sdb
           serial: v5V2zm-Lvbh-Mfx3-W8ki-COI9-DAtP-RXndhu
           size: 500GiB
           capacity: 500GiB
           capabilities: lvm2
           configuration: sectorsize=512
      *-disk:2
           description: SCSI Disk
           physical id: 0.2.0
           bus info: scsi@2:0.2.0
           logical name: /dev/sdc
           serial: fTQFJ2-giAV-WsXL-1Wha-V305-oQkV-qqS3SA
           size: 100GiB
           capacity: 100GiB
           capabilities: lvm2
           configuration: sectorsize=512
  4. 在 Hypervisor 主机上,使用总线信息找到虚拟机连接的磁盘。示例:SCSI(0:1)
  5. 扩展虚拟磁盘。有关说明,请参阅 VMware 知识库文章 1004047:http://kb.vmware.com/kb/1004047
  6. 重新登录到 SASE Orchestrator 系统控制台。
  7. 为已调整大小的物理卷重新扫描块设备。示例:
    echo 1 > /sys/block/$DEVICE/device/rescan

    示例:

    echo 1 > /sys/block/sdb/device/rescan
  8. 调整 LVM 物理磁盘的大小。
    pvresize /dev/sdb
  9. 确定数据库卷组中的可用空间量。
    vgdisplay store |grep Free

    示例:

    root@vco:~# vgdisplay store |grep Free
    Free  PE / Size       34560 / 135.00 GiB
  10. 扩展数据库逻辑卷。
    lvextend -r -L+#G /dev/store/data

    示例:

    root@vco1:~# lvextend -r -L+1G /dev/store/data
      Size of logical volume store/data changed from 400.00 GiB (102400 extents) to 401.00 GiB (102656 extents).
      Logical volume store/data successfully resized.
    resize2fs 1.44.1 (24-Mar-2018)
    Filesystem at /dev/mapper/store-data is mounted on /store; on-line resizing required
    old_desc_blocks = 50, new_desc_blocks = 51
    The filesystem on /dev/mapper/store-data is now 105119744 (4k) blocks long.
  11. 查看卷的新大小。
    df -h /dev/store/data

    示例:

    root@vco:~# df -h /dev/store/data
    Filesystem               Size  Used Avail Use% Mounted on
    /dev/mapper/store-data  379G  1.2G  359G   1% /store