Proper way to add witness and second CSV via Powershell

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

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

Post Reply
mearstech
Posts: 3
Joined: Sat May 19, 2018 8:53 pm

Sat May 19, 2018 9:06 pm

Hello,

2 Node Hyper-Converged Setup using Windows Server 2016

I have managed to get one CSV up and running via the attached script. It is a modified version of the CreateHA (2Node) powershell script. What is the proper method to add a second and third CSV to the Nodes? I have attempted to use the CreateImage script but that only creates the image on one node and doesn't sync to the others. I have also tried to just run the Same CreateHA (2Node) script and just change the names of the volume but this doesn't seem to fully work either.

Please advise of my error or proper way to create multiple CSV via powershell/ StarWindX.

Thanks, Jonathan.

CreateHAWitness

Code: Select all

Import-Module StarWindX
 
try
{
    $server = New-SWServer -host 100.10.10.1 -port 3261 -user root -password starwind
 
    $server.Connect()
 
    $firstNode = new-Object Node
 
    $firstNode.ImagePath = "My computer\K"
    $firstNode.ImageName = "Witness"
    $firstNode.Size = 1024
    $firstNode.CreateImage = $true
    $firstNode.TargetAlias = "vmwitness01"
    $firstNode.AutoSynch = $true
    $firstNode.SyncInterface = "#p2=100.10.10.2:3260"
    $firstNode.HBInterface = "#p2=100.10.20.2:3260"
    $firstNode.CacheSize = 64
    $firstNode.CacheMode = "wb"
    $firstNode.PoolName = "pool1"
    $firstNode.SyncSessionCount = 1
    $firstNode.ALUAOptimized = $true
     
    #
    # device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
    #
    $firstNode.SectorSize = 4096
     
    #
    # 'SerialID' should be between 16 and 31 symbols. If it not specified StarWind Service will generate it. 
    # Note: Second node always has the same serial ID. You do not need to specify it for second node
    #
    $firstNode.SerialID = "050176c0b535403ba3ce02102e33eac"
    #$secondNode.SerialID = "050176c0b535403ba3ce02102e33eac"
     
    $secondNode = new-Object Node
 
    $secondNode.HostName = "100.10.10.2"
    $secondNode.HostPort = "3261"
    $secondNode.Login = "root"
    $secondNode.Password = "starwind"
    $secondNode.ImagePath = "My computer\K"
    $secondNode.ImageName = "Witness"
    $secondNode.Size = 1024
    $secondNode.CreateImage = $true
    $secondNode.TargetAlias = "vmwitness02"
    $secondNode.AutoSynch = $true
    $secondNode.SyncInterface = "#p1=100.10.10.1:3260"
    $secondNode.HBInterface = "#p1=100.10.20.1:3260"
    $secondNode.ALUAOptimized = $true
         
    $device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
     
    $syncState = $device.GetPropertyValue("ha_synch_status")
 
    while ($syncState -ne "1")
    {
        #
        # Refresh device info
        #
        $device.Refresh()
 
        $syncState = $device.GetPropertyValue("ha_synch_status")
        $syncPercent = $device.GetPropertyValue("ha_synch_percent")
 
        Start-Sleep -m 2000
 
        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
    }
}
catch
{
    Write-Host "Exception $($_.Exception.Message)" -foreground red 
}
 
$server.Disconnect()

CreateHACSV01

Code: Select all

Import-Module StarWindX
 
try
{
    $server = New-SWServer -host 100.10.10.1 -port 3261 -user root -password starwind
 
    $server.Connect()
 
    $firstNode = new-Object Node
 
    $firstNode.ImagePath = "My computer\K"
    $firstNode.ImageName = "CSV01"
    $firstNode.Size = 450000
    $firstNode.CreateImage = $true
    $firstNode.TargetAlias = "vmsan01"
    $firstNode.AutoSynch = $true
    $firstNode.SyncInterface = "#p2=100.10.10.2:3260"
    $firstNode.HBInterface = "#p2=100.10.20.2:3260"
    $firstNode.CacheSize = 64
    $firstNode.CacheMode = "wb"
    $firstNode.PoolName = "pool1"
    $firstNode.SyncSessionCount = 1
    $firstNode.ALUAOptimized = $true
     
    #
    # device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
    #
    $firstNode.SectorSize = 4096
     
    #
    # 'SerialID' should be between 16 and 31 symbols. If it not specified StarWind Service will generate it. 
    # Note: Second node always has the same serial ID. You do not need to specify it for second node
    #
    $firstNode.SerialID = "050176c0b535403ba3ce02102e33eac"
    #$secondNode.SerialID = "050176c0b535403ba3ce02102e33eac"
    #$firstNode.SerialID = "050176c0b535403ba3ce02102e33eab"
     
    $secondNode = new-Object Node
 
    $secondNode.HostName = "100.10.10.2"
    $secondNode.HostPort = "3261"
    $secondNode.Login = "root"
    $secondNode.Password = "starwind"
    $secondNode.ImagePath = "My computer\K"
    $secondNode.ImageName = "CSV01"
    $secondNode.Size = 450000
    $secondNode.CreateImage = $true
    $secondNode.TargetAlias = "vmsan02"
    $secondNode.AutoSynch = $true
    $secondNode.SyncInterface = "#p1=100.10.10.1:3260"
    $secondNode.HBInterface = "#p1=100.10.20.1:3260"
    $secondNode.ALUAOptimized = $true
         
    $device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
     
    $syncState = $device.GetPropertyValue("ha_synch_status")
 
    while ($syncState -ne "1")
    {
        #
        # Refresh device info
        #
        $device.Refresh()
 
        $syncState = $device.GetPropertyValue("ha_synch_status")
        $syncPercent = $device.GetPropertyValue("ha_synch_percent")
 
        Start-Sleep -m 2000
 
        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
    }
}
catch
{
    Write-Host "Exception $($_.Exception.Message)" -foreground red 
}
 
$server.Disconnect()
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Sun May 20, 2018 11:16 am

What build of StarWind VSAN do you use? A couple of builds have had this issue lately.
mearstech
Posts: 3
Joined: Sat May 19, 2018 8:53 pm

Mon May 21, 2018 2:38 pm

According to the ReleaseNotes.txt in the ProgramFiles\StarWind folder I am seeing Version V8, build 11818 as the first entry. Is there a better way to confirm version? Is there a version that I should be using instead?

Thanks.
mearstech
Posts: 3
Joined: Sat May 19, 2018 8:53 pm

Mon May 21, 2018 3:43 pm

I have upgraded to the latest version v8 build 12166 and used the CreateHA(2node).ps1 and was able to create my disks. So far so good. If any issues arise I will reply here. Thanks.
Boris (staff)
Staff
Posts: 805
Joined: Fri Jul 28, 2017 8:18 am

Mon May 21, 2018 8:31 pm

Nice to know the updated build worked for you. Feel free to post any other questions to the community.
Post Reply