StarWind VSAN CreateHA_2.ps1 sample for CVM

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

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

Post Reply
yaroslav (staff)
Staff
Posts: 3067
Joined: Mon Nov 18, 2019 11:11 am

Sat Aug 03, 2024 8:38 pm

Code: Select all

param($addr="172.27.31.198", $port=3261, $user="root", $password="starwind",
	$addr2="172.27.31.199", $port2=$port, $user2=$user, $password2=$password,
#common
	$initMethod="NotSynchronize",
	$size=1024,
	$sectorSize=512,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
#primary node
	$imagePath="/mnt/sdb1/volume1",
	$imageName="test2",
	$createImage=$true,
	$storageName="",
	$targetAlias="test2",
	$poolName="pool1",
	$syncSessionCount=1,
	$aluaOptimized=$true,
	$cacheMode="none",
	$cacheSize=0,
	$syncInterface="#p2=172.16.20.231:3260,172.27.21.231:3260",
	$hbInterface="#p2=172.16.10.231:3260,172.27.31.199:3260",
	$createTarget=$true,
	$bmpFolderPath="",
#secondary node
	$imagePath2="/mnt/sdb1/volume1",
	$imageName2="test2",
	$createImage2=$true,
	$storageName2="",
	$targetAlias2="test2",
	$poolName2="pool1",
	$syncSessionCount2=1,
	$aluaOptimized2=$false,
	$cacheMode2=$cacheMode,
	$cacheSize2=$cacheSize,
	$syncInterface2="#p1=172.16.20.230:3260,172.27.21.230:3260",
	$hbInterface2="#p1=172.16.10.230:3260,172.27.31.198:3260",
	$createTarget2=$true,
	$bmpFolderPath2=""
	)
	
That's the top section of the script. This one is for creating a 2-node HA device, still same applies to CreateHA_3.ps1 and devices created with a heartbeat failover strategy.
Parameters description can be found here https://www.starwindsoftware.com/resour ... chine-cvm/

HINT1
initMethod can be
NotSynchronize - skips synchronization (works ONLY IF THERE IS NO DATA TO SKIP THE ORIGINAL SYNCHRONIZATION).
Clear - default
SyncFromFirst or SyncFromSecond or SyncFromThird - runs full synchronization from the specific node. Use it for recreating replicas.

HINT2
Size is in MB.

HINT3
Check more on bitmap types here https://knowledgebase.starwindsoftware. ... a-devices/.
If you are not sure which one to choose or if there is no faster storage than the DATA disk connected, leave it as is.

HINT4
/ and \ in imagePath are not the same :)

HINT5
imageName can be whatever you like and aligns with ASCII. I always use the same name for simplicity.

HINT6
storageName is used only if you plan adding the partner to the existing device. For CreateHA_2.ps1 use, leave it as is.

HINT7
Do not change poolName.

HINT8
Before turning on the cache read these KBs
How cache works https://knowledgebase.starwindsoftware. ... rinciples/
How to remove RAM cache https://knowledgebase.starwindsoftware. ... -l1-cache/ and SSD cache
Full synchronization causes https://knowledgebase.starwindsoftware. ... may-start/
What to do in case of blackout (sync may not start automatically after power failures/restart mishandles when the write-back cache is on) https://knowledgebase.starwindsoftware. ... -blackout/

HINT9
Make sure that at least one StarWind comm goes over a different NIC to avoid split-brain https://www.starwindsoftware.com/blog/w ... -avoid-it/
More at https://www.starwindsoftware.com/system-requirements
You are welcome to add multiple $syncInterface= and $hbInterface= IPs (yes, you need to type the IP address of the partner as a value).

HINT10
root/starwind are the default credentials to communicate with the service. They stay the same regardless of the CVM credentials (we plan to align them in the future)
yaroslav (staff)
Staff
Posts: 3067
Joined: Mon Nov 18, 2019 11:11 am

Sun Nov 17, 2024 1:10 pm

Well, I guess it makes sense to expand this topic a bit.
Adding here a script for Windows-based VSAN installations. Tested for Windows Server 2019 Standard and StarWind VSAN 15554. This should apply to the older versions.
Also, shout out to arorris (viewtopic.php?f=5&t=5624&p=31505&hilit=tip+3#p31505). Check this out. I basically improved his version of the script.

Code: Select all

param($addr="172.27.31.146", $port=3261, $user="root", $password="starwind",
	$addr2="172.27.31.144", $port2=$port, $user2=$user, $password2=$password,
#common
	$initMethod="NotSynchronize",
	$size=1024,
	$sectorSize=4096,
	$failover=0,
	$bmpType=1,
	$bmpStrategy=0,
#primary node
	$imagePath="My computer\C\starwind",
	$imageName="test1",
	$createImage=$true,
	$storageName="",
	$targetAlias="test1",
	$poolName="pool1",
	$syncSessionCount=1,
	$aluaOptimized=$true,
	$cacheMode="none",
	$cacheSize=0,
	$syncInterface="#p2=10.9.9.8:3260",
	$hbInterface="#p2=10.9.8.8:3260,172.27.31.144:3260",
	$createTarget=$true,
	$bmpFolderPath="",
#secondary node
	$imagePath2="My computer\C\starwind",
	$imageName2="test1",
	$createImage2=$true,
	$storageName2="",
	$targetAlias2="test1",
	$poolName2="pool1",
	$syncSessionCount2=1,
	$aluaOptimized2=$false,
	$cacheMode2=$cacheMode,
	$cacheSize2=$cacheSize,
	$syncInterface2="#p2=10.9.9.7:3260",
	$hbInterface2="#p2=10.9.8.7:3260,172.27.31.146:3260",
	$createTarget2=$true,
	$bmpFolderPath2=""
	)
The hints above still apply. More hints

HINT1
Turn off the firewall or make sure to open 3261 and 3260 ports.
Occasionally, firewall and Windows Defender might cause connectivity issues. Better turn them off and reboot the system.

HINT2
MTU. Align them. Please.

HINT3 (Applies to CVM in Windows too)
If you are about to use multiple iSCSI connections in Windows (i.e., 127.0.0.1 and 2x partner), Set iScsiDiscoveryListInterfaces to 1.
1. Make sure StarWind devices (if there are any) are synchronized.
2. Make sure StarWind devices are connected from both replication partners to all nodes that use the StarWind shared storage.
3. Stop StarWindService for one node.
NOTE: for StarWind CVM run

Code: Select all

sudo systemctl stop starwind-virtual-san
4. Go to C:\Program files\StarWind Software\StarWind.
NOTE: for StarWind CVM the path is /opt/starwind/starwind-virtual-san/drive_c/starwind/StarWind.cfg
5. Copy StarWind.cfg
6. Edit StarWind.cfg as suggested above.
7. Start StarWindService.
NOTE: for StarWind CVM run

Code: Select all

sudo systemctl start starwind-virtual-san
8. Wait for fast synchronization to complete.
9. Repeat for the remaining node.
It applies to compute- and storage-separated scenarios too.

HINT4
The script does not create a directory. Make sure you create the directory listed as $imagePath value before running the script. You can create a directory per file. Yeah, it will look much tidier.

HINT5
If something went sideways, and you want to try the script over again with the same imagename, targetalias, and the same path make sure to do the following for one node at a time.
1. Stop StarWind Service.
2. Go to C:\Program files\StarWind Software\StarWind\headers and delete the headers you do not need.
NOTE: for StarWInd CVM /opt/starwind/starwind-virtual-san/drive_c/starwind/headers
3. Go to the underlying storage specified as $imagePath and delete the header and imagefile there.
4. Go to StarWind.cfg; copy it.
6. Navigate under <targets>, remove target you do not need.
7, Navigate under <devices>, remove the device entry yo do not need.
8. Start the service, and let other devices - if there are any - fast sync.
9. Repeat for the remaining StarWind VSAN instance.

HINT6
It is OK to have the same targetalias and imagename on different nodes.
namcv
Posts: 7
Joined: Fri Nov 15, 2024 8:38 am

Fri Nov 22, 2024 9:06 am

Dear Sir
According to the attached image, is the LUN creation unsuccessful? Because when I add it to esxi, it fails.
Attachments
Capture2.PNG
Capture2.PNG (114.65 KiB) Viewed 3164 times
Capture.PNG
Capture.PNG (232.66 KiB) Viewed 3164 times
yaroslav (staff)
Staff
Posts: 3067
Joined: Mon Nov 18, 2019 11:11 am

Fri Nov 22, 2024 9:35 am

You have a connectivity issue there.
Please note that your script is fundamentally different from what was shared above. Please also check if your system meets best practices (https://www.starwindsoftware.com/best-p ... practices/) and system requirements (https://www.starwindsoftware.com/system-requirements)
namcv
Posts: 7
Joined: Fri Nov 15, 2024 8:38 am

Fri Nov 22, 2024 11:02 am

Dear Sir,
Is it not possible to use the same card for both Data and Replication? I am testing so I only use 1 card for both Data and Replication.
namcv
Posts: 7
Joined: Fri Nov 15, 2024 8:38 am

Fri Nov 22, 2024 11:08 am

Thank you. Problem solved.
yaroslav (staff)
Staff
Posts: 3067
Joined: Mon Nov 18, 2019 11:11 am

Fri Nov 22, 2024 12:39 pm

Great news!
Yes, you can use the same NIC for data and replication, yet, you need to have at least one link (can be management/heartbeat/redundant data or sync) running from another NIC. See more https://www.starwindsoftware.com/system-requirements.
jsutton@sentinel.com
Posts: 1
Joined: Sat Dec 07, 2024 11:47 pm

Sun Dec 08, 2024 12:18 am

Hi All,
I have just created a 2 node cluster with vSAN free, and added storage pool through the gui when I finished the initial HA setup, the pool is called sdb1. I have been attempting to use the CreateHA_2.ps1 to create a volume and keep receiving "Invalid channel format [2]" when running the script. I am not sure where to look for typos, or script validation. As far as I can tell from samples and forum posts, I have the script edited correctly

I have three adapters on each node one for Data 192.168.2.0/24, Replication 172.16.1.0/24, Management 192.168.5.0/24.

Any help would be greatly appreciated.


param($addr="192.168.5.21", $port=3261, $user="root", $password="starwind",
$addr2="192.168.5.22", $port2=$port, $user2=$user, $password2=$password,
#common
$initMethod="Clear",
$size=20000,
$sectorSize=512,
$failover=0,
$bmpType=1,
$bmpStrategy=0,
#primary node
$imagePath="/mnt/vol1",
$imageName="masterImg21",
$createImage=$true,
$storageName="",
$targetAlias="targetha21",
$poolName="pool1",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="none",
$cacheSize=0,
$syncInterface="172.16.1.22:3260",
$hbInterface="192.168.2.22:3260,192.168.5.22:3260",
$createTarget=$true,
$bmpFolderPath="",
#secondary node
$imagePath2="/mnt/vol1",
$imageName2="partnerImg22",
$createImage2=$true,
$storageName2="",
$targetAlias2="partnerha22",
$poolName2="pool1",
$syncSessionCount2=1,
$aluaOptimized2=$false,
$cacheMode2=$cacheMode,
$cacheSize2=$cacheSize,
$syncInterface2="172.16.1.21:3260",
$hbInterface2="192.168.2.21:3260,192.168.5.21:3260",
$createTarget2=$true,
$bmpFolderPath2=""
)

Import-Module StarWindX
yaroslav (staff)
Staff
Posts: 3067
Joined: Mon Nov 18, 2019 11:11 am

Sun Dec 08, 2024 7:41 am

Your IP address lines are missing p, partner identifier. See my script above for more details.
Post Reply