Wednesday, December 27, 2017

vSAN troubleshooting Commands

RVC login
localhost:~ #rvc
localhost:~ #domain\user@localhost

Disk Component Resync
Show component resync status
vsan.resync_dashboard .

Show all disk status (used/reserved, disk health, disk version)
vsan.disks_stats .

Disk Rebalance
Start Rebalance disks
vsan.proactive_rebalance --start --time-span 86400 --variance-threshold 0.30 --time-threshold 1800 --rate-threshold 100000 <cluster path>

Stop Rebalance disks
vsan.proactive_rebalance --stop <cluster path>

Check Rebalance status
vsan.proactive_rebalance_info /localhost/SouthEast/computers/Raleigh
vsan.resync_dashboard /localhost/SouthEast/computers/Raleigh

Cluster
Remove host or witness from fault domain
esxcli vsan cluster leave

Troubleshoot
esxcli vsan cluster get
vsan.check_state .
vsan.disks_info <host path>

Stress Test
/localhost/SouthCentral/computers/Houston> vsan.health.cluster_load_test_run -r houston_stress -t "Stress test" -d 28800 ./

Check vSAN upgrade status
vsan.upgrade_status -r 60 /localhost/VSAN-DC/computers/VSAN-Cluster/ 

Decrypt Files from QNAP with OpenSSL

If you have encryption enabled on your QNAP storage, to decrypt it, do the following.

Decrypt one file
     openssl enc -d -aes-256-cbc -k <decrypt password> -in filename.jpg -out filename.jpg


Decrypt multiple files in a folder.
     for f in * ; do [ -f $f ] && openssl enc -d -aes-256-cbc -k <decrypt password> -in $f -out _$f;

Change Network Failover Detection Policy on vSwitches and Portgroups

This script traverses all clusters and host and check if Beacon Probing is set the NetworkFailoverDetectionPolicy.  If Beacon Probing is set, change it to Link Status.

#import-module VMware.VimAutomation.Core
#Connect-VIServer -Server vcenter_hostname
#uncomment for testing
#$vmhosts = "hostname1","hostname2"
 
#uncomment for live run
#get the hostnames of all the hosts in every cluster
$vmhosts = get-cluster | get-vmhost | select name
foreach($vmhost in $vmhosts)
{
    #Gets all the vSwitch names that has beacon probing set on the host.
    $switch_policy = Get-VirtualSwitch -VMHost $vmhost.Name | where {$_.Name -ne "vSwitchiDRACvusb"} | Get-NicTeamingPolicy | Where-Object {$_.NetworkFailoverDetectionPolicy -eq "BeaconProbing"} | select -ExpandProperty VirtualSwitch # | select VirtualSwitch | format-wide
    if ($switch_policy)
    {
        foreach ($switch in $switch_policy)
        {
            $vs = Get-VirtualSwitch -VMHost $vmhost.Name -Name $switch
            Get-NicTeamingPolicy -VirtualSwitch $vs | Set-NicTeamingPolicy -NetworkFailoverDetectionPolicy LinkStatus
        }
    }
 
    #Gets all the port group names that has beacon probing set on the host.
    $portgroup_policy = Get-VirtualPortGroup -VMHost $vmhost | Get-NicTeamingPolicy | Where-Object {$_.NetworkFailoverDetectionPolicy -eq "BeaconProbing"} | select -ExpandProperty VirtualPortGroup
    if ($portgroup_policy)
    {
        foreach ($p in $portgroup_policy)
        {
            #Sets the nicteamingpolicy from the host and its portgroup.
            $vpg = Get-VirtualPortGroup -VMHost $vmhost.Name -Name $p
            Get-NicTeamingPolicy -VirtualPortGroup $vpg | Set-NicTeamingPolicy -NetworkFailoverDetectionPolicy LinkStatus
        }
    }
}