StarWind VSAN CreateHA_2.ps1 sample for CVM

Software-based VM-centric and flash-friendly VM storage + free version
yaroslav (staff)
Staff
Posts: 4425
Joined: Mon Nov 18, 2019 11:11 am

Fri Apr 11, 2025 3:06 pm

Please remove $addr from the sync interfaces. See more here viewtopic.php?f=5&t=6852&p=37208&hilit=HINT8#p37208.
Please also make sure that the StarWindX module and VSAN on both nodes is the same.
As a side note: I'd rather not use cache as it makes the HA devices more touch.
I will need to discuss this case internally. I will keep you posted.
Fonzies50
Posts: 1
Joined: Wed Aug 26, 2026 7:30 pm

Wed Aug 26, 2026 7:40 pm

Help for error invalid channel format [2]

Code: Select all

param(
	$addr="172.22.22.37", $port=3261, $user="root", $password="starwind",
	$addr2="172.22.22.38", $port2=3261, $user2=$user, $password2=$password,
#common
	$initMethod="Clear",
	$size=500720,
	$sectorSize=512,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
    [Uint32][ValidateRange(0, 4294967294)]
	$maxUnmap=128,
#primary node
	$imagePath="/mnt/[b]sdb1[/b]/vm-volume0", #IT'S RIGHT! see secondary node
	$imageName="HAVolume01",
	[bool][ValidateSet($false, $true)]
	$createImage=$true,
	$storageName="",
	$targetAlias="target-vsan01",
	$poolName="",
	$syncSessionCount=1,
	[bool][ValidateSet($false, $true)]
	$aluaOptimized=$true,
	$cacheMode="wt",
	$cacheSize=1024,
	$syncInterface="172.31.31.38:3260", # IP Partner Sincronizzazione (Nodo 2)
	$hbInterface="172.21.21.38",   # IP Partner Dati/Heartbeat (Nodo 2)
	[bool][ValidateSet($false, $true)]
	$createTarget=$true,
	$bmpFolderPath="",
#secondary node
	$imagePath2="/mnt/[b]vdb1[/b]/vm-volume0",  #IT'S RIGHT! see primary node
	$imageName2="HAVolume01",
	[bool][ValidateSet($false, $true)]
	$createImage2=$true,
	$storageName2="",
	$targetAlias2="target-vsan01",
	$poolName2="",
	$syncSessionCount2=1,
	[bool][ValidateSet($false, $true)]
	$aluaOptimized2=$false,
	$cacheMode2=$cacheMode,
	$cacheSize2=$cacheSize,
	$syncInterface2="172.31.31.37:3260", # IP Partner Sincronizzazione (Nodo 1)
	$hbInterface2="172.21.21.37",  # IP Partner Dati/Heartbeat (Nodo 1)
	[bool][ValidateSet($false, $true)]
	$createTarget2=$true,
	$bmpFolderPath2=""
	)

	
Import-Module StarWindX

try
{
	Enable-SWXLog

	$server = New-SWServer -host $addr -port $port -user $user -password $password

	$server.Connect()

	$firstNode = new-Object Node

	$firstNode.HostName = $addr
	$firstNode.HostPort = $port
	$firstNode.Login = $user
	$firstNode.Password = $password
	$firstNode.ImagePath = $imagePath
	$firstNode.ImageName = $imageName
	$firstNode.Size = $size
	$firstNode.CreateImage = $createImage
	$firstNode.StorageName = $storageName
	$firstNode.TargetAlias = $targetAlias
	$firstNode.SyncInterface = $syncInterface
	$firstNode.HBInterface = $hbInterface
	$firstNode.PoolName = $poolName
	$firstNode.SyncSessionCount = $syncSessionCount
	$firstNode.ALUAOptimized = $aluaOptimized
	$firstNode.CacheMode = $cacheMode
	$firstNode.CacheSize = $cacheSize
	$firstNode.FailoverStrategy = $failover
	$firstNode.CreateTarget = $createTarget
	$firstNode.BitmapStoreType = $bmpType
	$firstNode.BitmapStrategy = $bmpStrategy
	$firstNode.BitmapFolderPath = $bmpFolderPath
	$firstNode.MaxUnmap = $maxUnmap
	$firstNode.SectorSize = $sectorSize
    
	$secondNode = new-Object Node

	$secondNode.HostName = $addr2
	$secondNode.HostPort = $port2
	$secondNode.Login = $user2
	$secondNode.Password = $password2
	$secondNode.ImagePath = $imagePath2
	$secondNode.ImageName = $imageName2
	$secondNode.CreateImage = $createImage2
	$secondNode.StorageName = $storageName2
	$secondNode.TargetAlias = $targetAlias2
	$secondNode.SyncInterface = $syncInterface2
	$secondNode.HBInterface = $hbInterface2
	$secondNode.SyncSessionCount = $syncSessionCount2
	$secondNode.ALUAOptimized = $aluaOptimized2
	$secondNode.CacheMode = $cacheMode2
	$secondNode.CacheSize = $cacheSize2
	$secondNode.FailoverStrategy = $failover
	$secondNode.CreateTarget = $createTarget2
	$secondNode.BitmapFolderPath = $bmpFolderPath2
	$secondNode.MaxUnmap = $maxUnmap
        
	Write-Host "Creazione del dispositivo HA in corso..." -ForegroundColor Cyan
	$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod $initMethod
	if(!$device) { return }
    
	# Controllo basato sulla proprieta stringa di StarWind Linux (1 = Sincronizzato)
	while ($device.GetPropertyValue("ha_synch_status") -ne "1")
	{
		$syncPercent = $device.GetPropertyValue("ha_synch_percent")
		Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow

		Start-Sleep -Seconds 5

		$device.Refresh()
	}
	Write-Host "Sincronizzazione completata con successo!" -ForegroundColor Green
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	if ($server -and $server.Connected)
	{
		$server.Disconnect()
	}
}
What's wrong?
yaroslav (staff)
Staff
Posts: 4425
Joined: Mon Nov 18, 2019 11:11 am

Wed Aug 26, 2026 8:03 pm

Hi,

-port is missing.
-sync type is not optimal,
-some strange characters in the script.

You can grab the script from here viewtopic.php?f=5&t=6852&p=37208&hilit=HINT8#p37208.
Post Reply