StarWind VSAN CreateHA_2.ps1 sample for CVM

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

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

namcv
Posts: 17
Joined: Fri Nov 15, 2024 8:38 am

Sun Feb 09, 2025 3:10 pm

Thanks for your reminder, I will post the script for other members to refer to, if needed.
Attachments
sw5.PNG
sw5.PNG (164.51 KiB) Viewed 9957 times
adminr
Posts: 19
Joined: Tue Jan 14, 2025 12:11 pm

Sun Feb 09, 2025 7:44 pm

Do I need to change the root default password or can I just disable SSH in the CVM after configuration?

And as for the pool name, I have set my own name and everything is working fine. How might this affect the service in the future?
yaroslav (staff)
Staff
Posts: 3424
Joined: Mon Nov 18, 2019 11:11 am

Mon Feb 10, 2025 4:17 am

Thanks for sharing!
I am glad to read it worked. poolName relates to SMI-S work. It is better to leave it as is.
The root password is not common knowledge. Also, root logins are disabled, so leave it as is (you still can change it if your regulations say so).
adminr
Posts: 19
Joined: Tue Jan 14, 2025 12:11 pm

Mon Feb 10, 2025 7:53 am

yaroslav (staff) wrote:
Mon Feb 10, 2025 4:17 am
Thanks for sharing!
I am glad to read it worked. I need to clarify on poolname. I will update this comment once I find out.
The root password is not common knowledge. Also, root logins are disabled, so leave it as is (you still can change it if your regulations say so).
but if someone gets and runs the SW PowerShell scripts, they can break the system because the password is publicly available.

and I still miss understanding about Automatic Storage Rescan. I did everything according instruction but I don't get what actually it does and what is triggered this feature.
yaroslav (staff)
Staff
Posts: 3424
Joined: Mon Nov 18, 2019 11:11 am

Mon Feb 10, 2025 8:14 am

Nope, that "someone" has to be on your network and know about StarWind VSAN; this being said, it must be someone from the inside of your network or an intruder who broke in.
Yes, that's not secure and you are welcome to change it (https://forums.starwindsoftware.com/vie ... php?t=6001 and https://forums.starwindsoftware.com/vie ... ord#p28708). This password is for interaction between the VSAN service and the Management console. Do not confuse it with the credentials you use to log into the system or root access to the VM.
and I still miss understanding about Automatic Storage Rescan. I did everything according to instruction but I don't get what actually it does and what is triggered this feature.
Does the script trigger the rescan of the ESXi storage? If yes, you've configured it right.
As the name implies, the script rescans the iSCSI-connected StarWind VSAN storage. ESXi cannot reconnect the targets automatically after the device gains its synchronized status back (not synchronized devices are not available over iSCSI), and therefore, the targets might be available only from one node unless the rescan is issued. Script issues that rescan.
namcv
Posts: 17
Joined: Fri Nov 15, 2024 8:38 am

Mon Mar 31, 2025 7:40 am

Dear Sir,
When I have successfully created HA for 2 nodes. If my 1 note fails. Suppose I have another server, then I build a new note. So how do I add a new note to replace the failed note. Please guide me.

Tks!
yaroslav (staff)
Staff
Posts: 3424
Joined: Mon Nov 18, 2019 11:11 am

Mon Mar 31, 2025 7:58 am

Hi,

There are two scripts in the library. Remove the replica with the script and then add the new replication partner with the script.
You should be already familiar with the syntax for the latter.
namcv
Posts: 17
Joined: Fri Nov 15, 2024 8:38 am

Mon Mar 31, 2025 8:19 am

Dear Sir,
I want to ask a little more clearly.
First I will run the script "RemoveHAPartner.ps1" to remove the faulty node. Then I will run the script "CreateHA_2.ps1" to add a new note to replace the faulty node. And this does not lose the existing data, right?

Tks!
yaroslav (staff)
Staff
Posts: 3424
Joined: Mon Nov 18, 2019 11:11 am

Mon Mar 31, 2025 9:49 am

Hi,

The second step should be AddHApartner or something that looks like that.
namcv
Posts: 17
Joined: Fri Nov 15, 2024 8:38 am

Fri Apr 04, 2025 2:32 am

Dear Sir,
Thanks for your reply.
I used RemoveTarget.ps1 to delete Lun. But I am unable to delete or reformat Volume. Please help
namcv
Posts: 17
Joined: Fri Nov 15, 2024 8:38 am

Fri Apr 04, 2025 10:10 am

Dear Sir,
I have 2 vsan running HA. SW02: 172.16.222.242; SW03: 172.16.222.243.
When SW03 fails.
First I remove SW03 from SW02 in Appliances. Then run the script RemoveHAPartner.ps1.
After reinstalling the new SW03 with the old parameters - go to Storage\Volumes.
I added the new SW03 to SW02 in Appliances.
And finally run the script AddHAPartner.ps1.
But the result in Storage\LUNS says Limited availability instead of High Availability.
Please see the code and help me



param($addr="172.16.222.242", $port=3261, $user="root", $password="starwind", $deviceName="HAImage1",
$addr2="172.16.222.243", $port2=$port, $user2=$user, $password2=$password,
#secondary node
$imagePath2="/mnt/sdb1/volume1",
$imageName2="HA_vSan",
$createImage2=$true,
$targetAlias2="HA_vSan",
$autoSynch2=$true,
$poolName2="pool1",
$syncSessionCount2=1,
$aluaOptimized2=$true,
$syncInterface2="#p1=10.10.50.242:3260", # ip cua SYNC
$hbInterface2="#p1=192.168.50.242:3260", # ip cua data san
$bmpType=1,
$bmpStrategy=0,
$bmpFolderPath="",
$selfSyncInterface="#p2=10.10.50.243:3260", # ip cua SYNC
$selfHbInterface="#p2=192.168.50.243:3260" # ip cua data san
)
yaroslav (staff)
Staff
Posts: 3424
Joined: Mon Nov 18, 2019 11:11 am

Sat Apr 05, 2025 8:11 pm

It is intended to be limited availability until synchronization is over.
namcv
Posts: 17
Joined: Fri Nov 15, 2024 8:38 am

Tue Apr 08, 2025 1:18 am

Thank you very much!
yaroslav (staff)
Staff
Posts: 3424
Joined: Mon Nov 18, 2019 11:11 am

Tue Apr 08, 2025 1:39 am

Hi,

You are welcome.
FireMedic
Posts: 4
Joined: Tue May 25, 2021 4:04 pm

Fri Apr 11, 2025 2:45 pm

I am creating a 2 node Hyper-V cluster with an SMB Witness using the CreateHASmbWitness.ps1 script. However it seems to have created both sides with the same target name/IQN. This seems to be causing problems with cross connecting iscsi between the two nodes. How do I change the iqn name? Do I edit the HA.swdsk file under resources>storage for the current node and under the "<node id="2"... for the partner node?

This is the script CreateHASmbWitness script I used. Not sure how to specify the target names/IQNs in it. I tried setting the $storageName parameter but that gave a connection error when I ran the script.

param($addr="192.168.254.24", $port=3261, $user="root", $password="starwind",
$addr2="192.168.254.23", $port2=$port, $user2=$user, $password2=$password,
#common
$initMethod="Clear",
$size=1024,
$sectorSize=4096,
$bmpType=1,
$bmpStrategy=0,
$smbWitnessFilePath="\\nas1.hamilton.local\witness\Starwind\vSANVM_witness.dat",
$smbWitnessUsername="witness",
$smbWitnessPassword="xxxxx",
#primary node
$imagePath="My computer\E\vSAN",
$imageName="vSANVM",
$createImage=$true,
$storageName="",
$targetAlias="vSANVM",
$poolName="pool1",
$syncSessionCount=1,
$aluaOptimized=$true,
$cacheMode="wb",
$cacheSize=1024,
$syncInterface="#p2=192.168.252.132:3260" -f $addr2,
$bmpFolderPath="",
$createTarget=$true,
#secondary node
$imagePath2="My computer\E\vSAN",
$imageName2="vSANVM",
$createImage2=$true,
$storageName2="",
$targetAlias2="vSANVM",
$poolName2="pool1",
$syncSessionCount2=1,
$aluaOptimized2=$false,
$cacheMode2=$cacheMode,
$cacheSize2=$cacheSize,
$syncInterface2="#p1=192.168.252.133:3260" -f $addr,
$bmpFolderPath2="",
$createTarget2=$true
)

Here is the HA.swdsk file for the HV1 node.

<system>
<resources>
<storages>
<storage id="1" name="RAM" type="RAM">
<interval size="1" units="GB"/>
</storage>
<storage id="2" name="imagefile1" type="device" lun="0x0">
<interval size="1" units="GB"/>
</storage>
<storage id="3" name="\\nas1.hamilton.local\witness\Starwind\vSANVM_witness.dat" type="smb_witness">
<authentication type="basic">
<basic login="witness" passwd="0b6DtlS5XJeHWTZYIi1ENUHg=="/>
</authentication>
</storage>
<storage id="4" name="iqn.2008-08.com.starwindsoftware:spf03-hv1.hamilton.local-vsanvm" type="remote" lun="0x0">
<!-- iqn.2008-08.com.starwindsoftware:spf03-hv1.hamilton.local-vsanvm -->
<transport type="iSCSI">
<links>
<link id="1" type="data" priority="1" connections="1">
<peer ip="192.168.252.132" port="3260"/>
</link>
</links>
</transport>
</storage>
</storages>
<network/>
</resources>
</system>
<node id="1" name="HAImage" shut="false" active="true" flags="0">
<storages>
<storage_ref id="2"/>
</storages>
<parameters>
<type>1</type>
<priority>0</priority>
<auto_sync>true</auto_sync>
<sync_status>1</sync_status>
<sync_delay>50</sync_delay>
<sync_traffic_share>50</sync_traffic_share>
<failover_conf>1</failover_conf>
<witness_type>1</witness_type>
<last_sync_snap_id>0</last_sync_snap_id>
<alua_access_state>0</alua_access_state>
</parameters>
</node>
<node id="2" name="iqn.2008-08.com.starwindsoftware:spf03-hv1.hamilton.local-vsanvm" shut="false" active="true">
<storages>
<storage_ref id="4"/>
</storages>
<parameters>
<type>1</type>
<priority>1</priority>
<sync_status>1</sync_status>
<alua_access_state>0</alua_access_state>
<type_bitmap>RAM</type_bitmap>
</parameters>
</node>
</header>
Post Reply