Computer >> 컴퓨터 >  >> 소프트웨어 >> 가상 기기

PowerCLI를 통해 VMFS 데이터 저장소의 여유 공간 확인

이 기사에서는 VMWare vSphere 데이터 저장소의 여유 공간을 확인하고 가상 머신 씬 가상 디스크의 총 크기(동적 확장)가 데이터 저장소의 총 크기를 초과하는 씬 프로비저닝 데이터 저장소를 감지하는 간단한 PowerCLI 스크립트를 보여줍니다. 인프라에 여러 VMWare 데이터 저장소가 있는 경우 이 PowerShell 스크립트를 사용하여 여유 공간의 양을 모니터링하고 스토리지 초과 커밋이 있는 데이터 저장소를 감지하는 것이 쉽습니다(모든 VM의 씬 디스크에 대한 공간 요구 사항은 VMFS 데이터 저장소의 사용 가능한 공간보다 큽니다. ). 스크립트를 사용하여 VM을 생성하기 전에 사용된 공간의 증가를 분석하고 Thin Provision 오버 커밋 등의 데이터 저장소를 찾을 수 있습니다.

vSphere 인프라가 올바르게 작동하려면 VMWare VMFS 데이터 저장소에 최소 5-10%의 여유 공간을 확보하는 것이 좋습니다. 스냅샷(백업 시스템에서 생성된 스냅샷 포함)을 사용하는 경우 최소 10-15%의 여유 공간이 필요합니다.

VMWare 데이터 저장소의 여유 공간을 확인하고 표시하려면 아래 PowerShell 스크립트를 사용할 수 있습니다(VMWare vSphere PowerCLI 모듈이 컴퓨터에 이미 설치되어 있다고 가정함).

# Import the PowerCLI module into your PowerShell session
Import-Module VMware.VimAutomation.Core -ErrorAction SilentlyContinue
# Connect to vCenter host
Connect-VIServer mun-vcsa1 -User admin
# Get the list of vCenter darastores
$datastores = Get-Datastore
$ErrorActionPreference = 'SilentlyContinue'
# loop through all available datastores
ForEach ($datastore in $datastores)
{
# Find the size of the committed space of all thin disks in a datastore (how much space it is required if all vmdk files will grow to the sizes specified in their settings)
$Provision = ([Math]::Round(($datastore.ExtensionData.Summary.Capacity - $datastore.ExtensionData.Summary.FreeSpace + $datastore.ExtensionData.Summary.Uncommitted)/1GB,0))
# Percentage of free space in the datastore
$PerFree = ([math]::Round(($datastore.FreeSpaceGB)/($datastore.CapacityGB)*100,2))
# Percentage of thin disk overcommitment
$PerOvercommit = ([math]::Round($Provision/($datastore.CapacityGB)*100,2))
# Add extra properties to the datastore object
$datastore | Add-Member -type NoteProperty -name PercentsFree -value $PerFree
$datastore | Add-Member -type NoteProperty -name CapacityGb_r -value ([Math]::Round(($datastore.ExtensionData.Summary.Capacity)/1GB,0))
$datastore | Add-Member -type NoteProperty -name FreeSpaceGb_r -value ([Math]::Round(($datastore.ExtensionData.Summary.FreeSpace)/1GB,0))
$datastore | Add-Member -type NoteProperty -name ProvisionedSpaceGb -value $Provision
$datastore | Add-Member -type NoteProperty -name PercentsOvercommit -value $PerOvercommit
}
# Display the resulting data on VMWare datastores and export the output to a CSV file
$datastores|select-object Name, Type, Datacenter,CapacityGb_r,FreeSpaceGb_r,PercentsFree,ProvisionedSpaceGb,PercentsOvercommit|sort PercentsFree| Export-Csv C:\Reports\VMWareVMFSDatastores.csv -NoTypeInformation

PowerCLI를 통해 VMFS 데이터 저장소의 여유 공간 확인

Connect-VIServer를 사용하여 vCenter에 연결하려고 하고 오류가 표시되는 경우:

Could not resolve the requested VC server.Additional Information: There was no endpoint listening at https://mun-vcsa1/sdk that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details

PowerCLI가 프록시를 통해 VCSA에 연결을 시도할 가능성이 있습니다. PowerCLIConfiguration 실행 UseSystemProxy인지 확인하십시오. 보고. 그렇다면 다음 명령을 사용하여 PowerCLI에 대한 시스템 프록시를 비활성화하십시오.

Set-PowerCliConfiguration -proxypolicy noproxy

내 예에서 처음 5개의 VMFS 데이터스토어에 남은 여유 공간이 5% 미만임을 알 수 있습니다(녹색 상자). 일부 데이터스토어에 스토리지 오버커밋이 있습니다(데이터스토어에 있는 모든 씬 가상 디스크의 총 크기가 해당 크기를 초과함). 가상 VM 디스크가 설정에 지정된 최대 크기까지 커지기 시작하면 VMFS/NFS/VVOL 스토리지의 공간이 부족할 수 있습니다. (씩 디스크로 VM을 실행하면 평소와 같이 작동하지만 VSWAP 파일을 생성할 공간이 없기 때문에 새 VM을 시작할 수 없습니다.) 커밋된 공간이 전체 LUN 크기보다 큰 데이터 저장소는 다음과 같습니다. 노란색으로 강조 표시됩니다.
PowerCLI를 통해 VMFS 데이터 저장소의 여유 공간 확인

이 PowerShell 스크립트는 여유 공간이 부족한 VMWare 데이터 저장소를 빠르게 찾는 데 도움이 됩니다(Storage vMotion을 사용하여 데이터 저장소에서 VM을 마이그레이션할 수 있음).