Tue Oct 29, 2024 4:23 pm
Hi Yaroslav,
I try to find out how to create a simple HA with 2 nodes, unfortunately, with no success up to now.
after a while trying out the scripts delivered with the newest Version I went back to the ones from another thread here, cause they, at least, create an imagefile1 that is shown in the starwind console directly attached to the first node.
When you run the script, you can, at least, create an imagefile1 (or 2 or 3), when the "$imagename" is accepted. You have to alter the name every time, cause even if starwind.cfg stays unchanged, you delete the old imagefile, and restart Starwind VSAN Service, you´ll get an "200 - file already exists" then.
But when you choose an new one, only then, you get not only an "imagefile1" created under D:/VSAN, but also an "...swdsk.bak" file and you can see that the imagefile is directly attached (but greyed out) to the first node.
Screenshots that I saw show the imagefile under a device, not directly attached in the console.
But I don´t know how to create a device. There´s no such script under the samples.
Do you know why this is happening? Any help would be much appreciated. Thanks in advance!
Here´s the script that (partly) works:
(taken from vsan_scripts, "! 00 CreateHA_2.ps1"):
param
(
$addr="192.168.10.10", $port=3261, $user="root", $password="starwind",
$addr2="192.168.10.191", $port2=$port, $user2=$user, $password2=$password,
#common
$initMethod="syncFromFirst",
$size=1848576,
$sectorSize=4096,
$failover=0,
#primary node
$imagePath="My computer/D/VSAN",
$imageName="disk01image2",
$createImage=$true,
$storageName="",
$targetAlias="disk01target",
$autoSynch=$true,
$poolName="disk01pool",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="wb",
$cacheSize=128,
$syncInterface="#p2=192.168.10.179:3260" -f $addr2,
$hbInterface="#p2=172.16.10.2:3260.172.16.20.2:3260" -f $addr2,
$createTarget=$true,
#secondary node
$imagePath2="My computer/D/VSAN",
$imageName2="disk01image2",
$createImage2=$true,
$storageName2="",
$targetAlias2="disk01target",
$autoSynch2=$true,
$poolName2="disk01pool",
$syncSessionCount2=1,
$aluaOptimized2=$true,
$cacheMode2=$cacheMode,
$cacheSize2=$cacheSize,
$syncInterface2="#p1=192.168.10.9:3260" -f $addr,
$hbInterface2="#p1=172.16.10.1:3260,172.16.20.1:3260" -f $addr,
$createTarget2=$true
)
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.AutoSynch = $autoSynch
$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
#
# device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes.
#
$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.AutoSynch = $autoSynch2
$secondNode.SyncInterface = $syncInterface2
$secondNode.HBInterface = $hbInterface2
$secondNode.SyncSessionCount = $syncSessionCount2
$secondNode.ALUAOptimized = $aluaOptimized2
$secondNode.CacheMode = $cacheMode2
$secondNode.CacheSize = $cacheSize2
$secondNode.FailoverStrategy = $failover
$secondNode.CreateTarget = $createTarget2
$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod $initMethod
while ($device.SyncStatus -ne [SwHaSyncStatus]::SW_HA_SYNC_STATUS_SYNC)
{
$syncPercent = $device.GetPropertyValue("ha_synch_percent")
Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
Start-Sleep -m 2000
$device.Refresh()
}
}
catch
{
Write-Host $_ -foreground red
}
finally
{
$server.Disconnect()
}