扩容vCenter Server磁盘空间大小的两种方式

文章目录
  • 概述
  • API 方式
  • Shell 方式
  • 总结
  • 概述

    我们可以通过 VAMI 管理后台监控磁盘/分区的使用情况,vCenter Server 运行一段时间后,当利用率进度条显示为红色之后,说明磁盘空间即将占满,此时应该考虑对磁盘执行扩容操作。如果不及时进行扩容操作,或者因为其他原因导致磁盘的空间被完全占满,可能会造成服务中断以及 vCenter Server 使用故障。

    从 vSphere 6.0 开始,vCenter Server 就引入了  Logical Volume Management(LVM)逻辑卷管理,并且可以在不停机的情况下完成磁盘空间的动态扩容,这对于运维和管理来说变得十分方便。

    以 vSphere 7.0 为例,下面演示对 vCenter Server 进行磁盘扩容。

    API 方式

    使用 SSH 以 root 用户连接到 vCenter Server,输入 storage 并按 Tab 补全,可以看到具有多个用于存储的 API 命令,运行 storage.health.get 可以获取存储的健康状态

    运行 storage.list 可以获取 vCenter Server 所有的磁盘分区,Usedkbytes 表示已使用空间大小,Totalkbytes 表示总空间大小,单位是 KB;Usedinodes 表示已使用的 inode 数量,Totalinodes 表示总共的 inode 数量。

    Command> storage.stats.list
    Stats:
      ...
    
      14:
          Name: /storage/log
          Usedkbytes: 1395368
          Totalkbytes: 10210580
          Usedinodes: 1422
          Totalinodes: 655360
      ...
    
    Command>

    登录到 vSphere Client,找到 vCenter Server 虚拟机并点击编辑设置,展开硬盘选项卡可以看到 vCenter Server 的所有硬盘,这里演示给硬盘5扩容磁盘空间,也就是/storage/log分区,从 10 GB 扩容到 30 GB。

    注意:如果这里显示是灰色无法修改磁盘的空间大小,可能是因为虚拟机正在快照上运行,可以尝试删除 vCenter Server 虚拟机的所有快照,并在继续之前创建 vCenter Server 基于文件的完整备份。

    修改完成后,运行 storage.resize 命令以执行磁盘分区自动扩容。

    再次查看磁盘分区的空间大小,可以发现已成功增加。

    Command> storage.stats.list
    Stats:
      ...
    
      14:
          Name: /storage/log
          Usedkbytes: 1327656
          Totalkbytes: 30844924
          Usedinodes: 1411
          Totalinodes: 1966080
      ...
    Command>

    更直观的方式是登录设备管理(VAMI)查看

    Shell 方式

    同样使用 SSH 以 root 用户连接到 vCenter Server,默认情况下进入 API 命令行。使用以下命令开启 vCenter Server 的 Bash Shell 访问,再输入 shell 命令进行连接。

    shell.set --enabled true
    shell

    登录到 vSphere Client,找到 vCenter Server 虚拟机并点击编辑设置,展开硬盘选项卡,这里还是演示给硬盘5扩容磁盘空间,从 30 GB 扩容到 60 GB。

    完成编辑后,运行以下脚本

    /usr/lib/applmgmt/support/scripts/autogrow.sh

    完整输出过程如下

    root@localhost [ ~ ]# /usr/lib/applmgmt/support/scripts/autogrow.sh
    Fri May 9 02:23:43 UTC 2025 Disk Util: INFO: Scanning Hard disk sizes
    Syncing file systems
    which: no multipath in (/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/java/jre-vmware/bin:/opt/vmware/bin:/opt/vmware/bin)
    Scanning SCSI subsystem for new devices and remove devices that have disappeared
    Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, all LUNs
     Scanning for device 0 0 0 0 ...
    OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00
          Vendor: NECVMWar Model: VMware IDE CDR00 Rev: 1.00
          Type:   CD-ROM                           ANSI SCSI revision: 05
    Scanning host 1 for  SCSI target IDs  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, all LUNs
    Scanning host 2 for  SCSI target IDs  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, all LUNs
     Scanning for device 2 0 0 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 1 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 01 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 10 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 10 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 11 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 11 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 12 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 12 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 13 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 13 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 14 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 14 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 15 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 15 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 2 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 02 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 3 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 03 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 4 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 04 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 5 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 05 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 6 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 06 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 8 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 08 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 2 0 9 0 ...
    OLD: Host: scsi2 Channel: 00 Id: 09 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
    Scanning host 3 for  SCSI target IDs  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, all LUNs
     Scanning for device 3 0 0 0 ...
    OLD: Host: scsi3 Channel: 00 Id: 00 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
     Scanning for device 3 0 1 0 ...
    OLD: Host: scsi3 Channel: 00 Id: 01 Lun: 00
          Vendor: VMware   Model: Virtual disk     Rev: 1.0
          Type:   Direct-Access                    ANSI SCSI revision: 02
    Scanning host 4 for  SCSI target IDs  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15, all LUNs
    0 new or changed device(s) found.
    0 remapped or resized device(s) found.
    0 device(s) removed.
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sda
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdb
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdc
      Physical volume "/dev/sdc" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdd
      Physical volume "/dev/sdd" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sde
      Physical volume "/dev/sde" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdf
      Physical volume "/dev/sdf" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:47 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdg
      Physical volume "/dev/sdg" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdh
      Physical volume "/dev/sdh" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdi
      Physical volume "/dev/sdi" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdj
      Physical volume "/dev/sdj" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdk
      Physical volume "/dev/sdk" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdl
      Physical volume "/dev/sdl" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdm
      Physical volume "/dev/sdm" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdn
      Physical volume "/dev/sdn" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:48 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdo
      Physical volume "/dev/sdo" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:49 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdp
      Physical volume "/dev/sdp" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:49 UTC 2025 Disk Util: INFO: Resizing PV /dev/sdq
      Physical volume "/dev/sdq" changed
      1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    Fri May 9 02:23:49 UTC 2025 Disk Util: INFO: LV Resizing /dev/swap_vg/swap1
    fsadm: Filesystem "swap" on device "/dev/mapper/swap_vg-swap1" is not supported by this tool.
      Filesystem check failed.
    Fri May 9 02:23:49 UTC 2025 Disk Util: INFO: LV Resizing /dev/log_vg/log
      Size of logical volume log_vg/log changed from 29.99 GiB (3839 extents) to 59.99 GiB (7679 extents).
      Logical volume log_vg/log successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    Filesystem at /dev/mapper/log_vg-log is mounted on /storage/log; on-line resizing required
    old_desc_blocks = 4, new_desc_blocks = 8
    The filesystem on /dev/mapper/log_vg-log is now 15726592 (4k) blocks long.
    
    Fri May 9 02:23:50 UTC 2025 Disk Util: INFO: LV Resizing /dev/seat_vg/seat
      Size of logical volume seat_vg/seat unchanged from 9.99 GiB (1279 extents).
      Logical volume seat_vg/seat successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 2619392 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:50 UTC 2025 Disk Util: INFO: LV Resizing /dev/netdump_vg/netdump
      Size of logical volume netdump_vg/netdump unchanged from 1016.00 MiB (127 extents).
      Logical volume netdump_vg/netdump successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 260096 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:50 UTC 2025 Disk Util: INFO: LV Resizing /dev/vtsdb_vg/vtsdb
      Size of logical volume vtsdb_vg/vtsdb unchanged from 19.99 GiB (2559 extents).
      Logical volume vtsdb_vg/vtsdb successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 5240832 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:50 UTC 2025 Disk Util: INFO: LV Resizing /dev/imagebuilder_vg/imagebuilder
      Size of logical volume imagebuilder_vg/imagebuilder unchanged from 9.99 GiB (1279 extents).
      Logical volume imagebuilder_vg/imagebuilder successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 2619392 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:50 UTC 2025 Disk Util: INFO: LV Resizing /dev/lifecycle_vg/lifecycle
      Size of logical volume lifecycle_vg/lifecycle unchanged from 99.99 GiB (12799 extents).
      Logical volume lifecycle_vg/lifecycle successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 26212352 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:50 UTC 2025 Disk Util: INFO: LV Resizing /dev/db_vg/db
      Size of logical volume db_vg/db unchanged from 9.99 GiB (1279 extents).
      Logical volume db_vg/db successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 2619392 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:51 UTC 2025 Disk Util: INFO: LV Resizing /dev/core_vg/core
      Size of logical volume core_vg/core unchanged from 29.99 GiB (3839 extents).
      Logical volume core_vg/core successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 7862272 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:51 UTC 2025 Disk Util: INFO: LV Resizing /dev/vg_root_0/lv_root_0
      Size of logical volume vg_root_0/lv_root_0 unchanged from <48.00 GiB (12287 extents).
      Logical volume vg_root_0/lv_root_0 successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 12581888 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:51 UTC 2025 Disk Util: INFO: LV Resizing /dev/dblog_vg/dblog
      Size of logical volume dblog_vg/dblog unchanged from 14.99 GiB (1919 extents).
      Logical volume dblog_vg/dblog successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 3930112 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:51 UTC 2025 Disk Util: INFO: LV Resizing /dev/vtsdblog_vg/vtsdblog
      Size of logical volume vtsdblog_vg/vtsdblog unchanged from 4.99 GiB (639 extents).
      Logical volume vtsdblog_vg/vtsdblog successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 1308672 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:52 UTC 2025 Disk Util: INFO: LV Resizing /dev/vg_lvm_snapshot/lv_lvm_snapshot
      Size of logical volume vg_lvm_snapshot/lv_lvm_snapshot unchanged from 149.99 GiB (19199 extents).
      Logical volume vg_lvm_snapshot/lv_lvm_snapshot successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 39319552 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:52 UTC 2025 Disk Util: INFO: LV Resizing /dev/autodeploy_vg/autodeploy
      Size of logical volume autodeploy_vg/autodeploy unchanged from 9.99 GiB (1279 extents).
      Logical volume autodeploy_vg/autodeploy successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 2619392 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:52 UTC 2025 Disk Util: INFO: LV Resizing /dev/updatemgr_vg/updatemgr
      Size of logical volume updatemgr_vg/updatemgr unchanged from 99.99 GiB (12799 extents).
      Logical volume updatemgr_vg/updatemgr successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 26212352 (4k) blocks long.  Nothing to do!
    
    Fri May 9 02:23:52 UTC 2025 Disk Util: INFO: LV Resizing /dev/archive_vg/archive
      Size of logical volume archive_vg/archive unchanged from 49.99 GiB (6399 extents).
      Logical volume archive_vg/archive successfully resized.
    resize2fs 1.46.5 (30-Dec-2021)
    The filesystem is already 13105152 (4k) blocks long.  Nothing to do!
    root@localhost [ ~ ]#

    待脚本执行完成后登录设备管理(VAMI)查看磁盘分区的使用情况,可以发现磁盘空间大小已成功扩容。

    总结

    上述过程能够完成对 vCenter Server 磁盘的扩容操作,整个过程比较简单,可以根据个人习惯自行选择使用 API 或者 Shell 方式。

    0

    1. This post has no comment yet

    发表回复

    您的邮箱地址不会被公开。 必填项已用 * 标注

    Hyper-V虚拟机显卡直通(GPU Passthrough)
    Hyper-V虚拟机显卡直通(GPU Passthrough)
    Citrix NetScaler ADC 升级安全补丁
    Citrix NetScaler ADC 升级安全补丁
    VBR 12 备份Linux系统
    VBR 12 备份Linux系统
    VMware ESXi 9.0 Beta版本首发体验
    VMware ESXi 9.0 Beta版本首发体验
    解决ESXi SSL证书过期,无法登陆
    解决ESXi SSL证书过期,无法登陆
    使用DLVM本地部署DeepSeek(未完待续)
    使用DLVM本地部署DeepSeek(未完待续)
    © 2025 诺诺博客如有侵权请联系删除 | 网站地图 | 百度统计 | 又拍云CDN加速
    为了获得更好的浏览效果 建议您使用IE8.0及以上版本浏览器登陆本站点 · 服务器托管于腾讯云