cannot create device on nodes with the scripts

Software-based VM-centric and flash-friendly VM storage + free version

Moderators: anton (staff), art (staff), Max (staff), Anatoly (staff)

msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

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()
}
yaroslav (staff)
Staff
Posts: 3111
Joined: Mon Nov 18, 2019 11:11 am

Tue Oct 29, 2024 4:54 pm

Hi,

Welcome to StarWind Forum!
Are you using the Windows-based VSAN or CVM?
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Thu Oct 31, 2024 10:22 am

Hi Yaroslav,

the newest Windows version on 2 Windows Server 2022 Standard hosts.
Please also note that if you run the script (taken as said from the other thread, cause actual scripts didn´t work) "successfully", then the imagefile1 is created, but powershell ISE exits by itself and is restarted. Also strange behaviour...

Best regards!
Michael
yaroslav (staff)
Staff
Posts: 3111
Joined: Mon Nov 18, 2019 11:11 am

Thu Oct 31, 2024 10:53 am

Try cleaning up the configs before running the scripts or use unique names. This script works for sure (change the location and IPs viewtopic.php?f=5&t=6852&p=37208&hilit=HINT8#p37208)
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Fri Nov 01, 2024 11:13 am

Hi Yaroslav,

already tried that dozen times, went back to original scripts now:
Imagefile "masterimg21.img" is created at D:\VSAN, but there´s no second file there, only the image. Not like with the other script.
And not, noting is attached to the forst node in the console.

Script used exactly like in the Samples folder of original installation:

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="Clear",
$size=1848576,
$sectorSize=4096,
$failover=0,
$bmpType=1,
$bmpStrategy=0,
#primary node
$imagePath="My computer\D\VSAN",
$imageName="masterImg21",
$createImage=$true,
$storageName="",
$targetAlias="targetha21",
$poolName="pool1",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="none",
$cacheSize=0,
$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,
$bmpFolderPath="",
#secondary node
$imagePath2="My computer\D\VSAN",
$imageName2="partnerImg22",
$createImage2=$true,
$storageName2="",
$targetAlias2="partnerha22",
$poolName2="pool1",
$syncSessionCount2=1,
$aluaOptimized2=$false,
$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,
$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

#
# 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.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

$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()
}
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Fri Nov 01, 2024 11:22 am

OK, there was a typo between the ip´s of the Heartbeatadapters, corrected that, but noting changes: You get always a "200 - file already exists" error and nothing is inserted in "starwind.cfg".

Imagefile is created always, but always with the above error message. Noting is attatched to the first node then.

Only with the first script that I sent you, when 2 files are created under D:\VSAN, then an imagefile can be seen in the console:
But it is greyed out then, only on the first node, nothing on the second node.

I don´t senn a "device" being created, only an "imagefile". Is this by design? When I used the paid version, this was different...

Best regards
Michael
yaroslav (staff)
Staff
Posts: 3111
Joined: Mon Nov 18, 2019 11:11 am

Fri Nov 01, 2024 12:05 pm

Great news! I am glad that you managed to rule it out.
This basically confirms that there are some lines stuck in device or target areas in the *.cfg.
Please check StarWind.cfg and remove the existing entries. Try different target names and image file names.
You need to stop StarWindService on both nodes -> Edit StarWind.cfg of each (i.e., remove entries referring to imagefile, target or HA device) -> Save file and exit -> start the service -> try the script again.

If there are absolutely no entries under target and device lines, try restarting the StarWindServie.
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Fri Nov 01, 2024 1:13 pm

OK, on node 2, starwind.cfg was completely untouched. Although there wasn´t any entry in devices or under targets, I copied this original file to the starwind root directory of the first node and restarted the service once again on each node.

I did not modify the script: except I changed the filenames of the imagefiles, no message "200 - file already exists" was seen, but after executing the script, Powershell ISE restartet (why is this happening????)

There is some progress:
Now: on node 1, there are 2 files under D:\VSAN masterImg1.img and masterimg1.swdsk.bak
You can see in the console that this imagefile is attached to node 1.

But on node2, still nothing happens...


Script (I only change the filenames (bold)):
...
$imagePath="My computer\D\VSAN",
$imageName="masterImg1",
$createImage=$true,
$storageName="",
$targetAlias="targetha1",
$poolName="pool1",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="none",
$cacheSize=0,
$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,
$bmpFolderPath="",
#secondary node
$imagePath2="My computer\D\VSAN",
$imageName2="partnerImg1",
$createImage2=$true,
$storageName2="",
$targetAlias2="partnerha1",
...
yaroslav (staff)
Staff
Posts: 3111
Joined: Mon Nov 18, 2019 11:11 am

Fri Nov 01, 2024 1:39 pm

Good. The error occurs because there are conflicting entries in the StarWind.cfg. Please check StarWind.cfg.
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Fri Nov 01, 2024 9:42 pm

the only line that is created in starwind.cfg is:

<device name="imagefile1" header="Headers\masterImg1\masterImg1.swdsk"/>

and the 2 files are created at D:\VSAN of course.

Is there a need to manually edit starwind.cfg (there are a lot of examples commented out inside)?
yaroslav (staff)
Staff
Posts: 3111
Joined: Mon Nov 18, 2019 11:11 am

Sat Nov 02, 2024 3:41 am

Yes. Also, please delete the files from the underlying storage.
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Sat Nov 02, 2024 3:33 pm

Yaroslav, to be clear:
Of course I delete these files every time and of course, I remove every line (it´s only the one I told you) from starwind.cfg before a retry.

The system is always in the initial state. Otherwise you cannot create the two files and you won´t get the attached imagefile1 in the console.

But there should remain anywhere something, cause if you don´t change filenames in the script, the you´ll get always the "200 - file already exists" error. It is completely unclear, why this is happening! Couse service on both hosts is restarted every time and starwind.cfg is completely in the initial state.

Do you write something to the registry?
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Sat Nov 02, 2024 3:48 pm

That is:
To repeat the creation of the imagefile AND the swdsk.bak file, you have to change at least the line:

"....
$imageName="masterImg0",
...."

in the script from "masterimg1" to "masterimg0" and remove the line:

"<device name="imagefile1" header="Headers\masterImg0\masterImg0.swdsk"/>"

from starwind.cfg ( I double checked it with beyond compare, it´s the only difference excpt the "<UpdateLastRequest value="20241021"/>" which holds the update value.

And of course restarting the service and deleting the files. Is there anything I missed?

I didn´t find any information from what to do else?
yaroslav (staff)
Staff
Posts: 3111
Joined: Mon Nov 18, 2019 11:11 am

Sat Nov 02, 2024 5:10 pm

Please take this script, and replace only the path and IPs with your ones. I noticed that you are using $addr, while my script does not have that line (my script does not have those).
Try also using a different name for the target and image file name.
msgabler
Posts: 13
Joined: Tue Oct 29, 2024 4:09 pm

Sun Nov 03, 2024 12:22 pm

Hi, OK, your script works as well, but only so far that it creates the imagefile1 on node 1, on node 2 still nothing happens:

I´ve done what you recommended and changed only IP-Adresses and path and had to rename $imagefile.

Are the lines for the heartbeatinterfaces correct in that way? I got an "invalid parameter" when I left out the "#p1=" and "#p2=" ...


The script that I used now:
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="Clear",
$size=1848576,
$sectorSize=4096,
$failover=0,
$bmpType=1,
$bmpStrategy=0,
#primary node
$imagePath="My computer\D\VSAN",
$imageName="masterImg2",
$createImage=$true,
$storageName="",
$targetAlias="targetha2",
$poolName="pool1",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="none",
$cacheSize=0,
$syncInterface="#p2={0}:3260" -f $addr2,
$hbInterface="#p2=192.168.10.67:3260,192.168.10.144:3260",
$createTarget=$true,
$bmpFolderPath="",
#secondary node
$imagePath2="My computer\D\VSAN",
$imageName2="partnerImg2",
$createImage2=$true,
$storageName2="",
$targetAlias2="partnerha2",
$poolName2="pool1",
$syncSessionCount2=1,
$aluaOptimized2=$false,
$cacheMode2=$cacheMode,
$cacheSize2=$cacheSize,
$syncInterface2="#p1={0}:3260" -f $addr,
$hbInterface2="#p1=192.168.10.66:3260,192.168.10.79:3260",
$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

#
# 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.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

$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()
}
Post Reply