Issue Creating HAImage

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

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

Post Reply
dandickson
Posts: 2
Joined: Mon May 22, 2017 1:47 pm

Mon May 22, 2017 2:43 pm

I'm leaving the original post just in case someone else makes the same mistake as I:

Node.SyncInterface and Node.HBInterface refer to the opposing system, not the interface on the system you are referencing as that node.

Hi,

I'm trying to create a HAImage using only the powershell scripts, in my examples below, 192.168.69.15/10.255.255.15 is node 1 and 192.168.69.18/10.255.255.18 is node 2:

Code: Select all

#Import-Module StarWindX

try
{
    $server = New-SWServer -host 192.168.69.15 -port 3261 -user root -password starwind

    $server.Connect()

    $firstNode = new-Object Node

    $firstNode.ImagePath = "My computer\D\Storage"
    $firstNode.ImageName = "quorum"
    $firstNode.Size = 10240
    $firstNode.CreateImage = $true
    $firstNode.TargetAlias = "quorum"
    $firstNode.AutoSynch = $true
    $firstNode.SyncInterface = "#p2=10.255.255.15:3260"
    $firstNode.HBInterface = "#p2=192.168.69.15:3260"
    $firstNode.CacheSize = 64
    $firstNode.CacheMode = "wb"
    $firstNode.PoolName = "quorum"
    $firstNode.SyncSessionCount = 1
    $firstNode.ALUAOptimized = $true
    
    #
    # device sector size. Possible values: 512 or 4096(May be incompatible with some clients!) bytes. 
    #
    $firstNode.SectorSize = 512
	
	#
	# '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 = "050176c0b535403ba3ce02102e33eab" 
    
    $secondNode = new-Object Node

    $secondNode.HostName = "192.168.69.18"
    $secondNode.HostPort = "3261"
    $secondNode.Login = "root"
    $secondNode.Password = "starwind"
    $secondNode.ImagePath = "My computer\D\Storage"
    $secondNode.ImageName = "quorum"
    $secondNode.Size = 256
    $secondNode.CreateImage = $true
    $secondNode.TargetAlias = "quorum"
    $secondNode.AutoSynch = $true
    $secondNode.SyncInterface = "#p1=10.255.255.18:3260"
    $secondNode.HBInterface = "#p1=192.168.69.18: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()
Running the above results in the following:

Code: Select all

Exception Exception calling "CreateDevice" with "4" argument(s): "Error: 
200 Synchronization cannot be started because the nodes are not ready! Try to synchronize the nodes manually.
Pending. "
Running an enumDeviceTargets on Node 1 shows the device being created:

Code: Select all

Targets:


Name        : iqn.2008-08.com.starwindsoftware:192.168.69.15-quorum
Id          : 0x000000C4A94CF940
Alias       : quorum
IsClustered : True
Devices     : System.__ComObject
Permissions : System.__ComObject
Type        : 

Devices:
Name                    : HAImage1
DeviceType              : HA Image
DeviceId                : 0x000000C4A3786340
File                    : My computer\D\Storage\quorum_HA.swdsk
TargetName              : iqn.2008-08.com.starwindsoftware:192.168.69.15-quorum
TargetId                : 0x000000C4A94CF940
Size                    : 10737418240
CacheMode               : wb
CacheSize               : 64
CacheBlockExpiryPeriod  : 5000
Exists                  : True
DeviceLUN               : 0
IsSnapshotsSupported    : False
Snapshots               : 
SectorSize              : 512
Partners                : System.__ComObject
SynchronizationChannels : System.__ComObject
HeartbeatChannels       : System.__ComObject
SyncStatus              : 3

Name                   : imagefile1
DeviceType             : Image file
DeviceId               : 0x000000C4A46428C0
File                   : My computer\D\Storage\quorum.img
TargetName             : empty
TargetId               : empty
Size                   : 10737418240
CacheMode              : wb
CacheSize              : 64
CacheBlockExpiryPeriod : 5000
Exists                 : True
DeviceLUN              : 
IsSnapshotsSupported   : False
Snapshots              : 
SectorSize             : 512
And on node 2:

Code: Select all

Targets:


Name        : iqn.2008-08.com.starwindsoftware:192.168.69.15-quorum
Id          : 0x000000C4A94CF940
Alias       : quorum
IsClustered : True
Devices     : System.__ComObject
Permissions : System.__ComObject
Type        : 

Devices:
Name                    : HAImage1
DeviceType              : HA Image
DeviceId                : 0x000000C4A3786340
File                    : My computer\D\Storage\quorum_HA.swdsk
TargetName              : iqn.2008-08.com.starwindsoftware:192.168.69.15-quorum
TargetId                : 0x000000C4A94CF940
Size                    : 10737418240
CacheMode               : wb
CacheSize               : 64
CacheBlockExpiryPeriod  : 5000
Exists                  : True
DeviceLUN               : 0
IsSnapshotsSupported    : False
Snapshots               : 
SectorSize              : 512
Partners                : System.__ComObject
SynchronizationChannels : System.__ComObject
HeartbeatChannels       : System.__ComObject
SyncStatus              : 3

Name                   : imagefile1
DeviceType             : Image file
DeviceId               : 0x000000C4A46428C0
File                   : My computer\D\Storage\quorum.img
TargetName             : empty
TargetId               : empty
Size                   : 10737418240
CacheMode              : wb
CacheSize              : 64
CacheBlockExpiryPeriod : 5000
Exists                 : True
DeviceLUN              : 
IsSnapshotsSupported   : False
Snapshots              : 
SectorSize             : 512
However running the GetHASyncState using the following:

Code: Select all

#
# This following example shows how to get synchronization status of specified HA device and 
# if there is a need run synchronization
#
Import-Module StarWindX

try
{
    #
    # connect to the server
    #
    $server = New-SWServer -host 192.168.69.15 -port 3261 -user root -password starwind

    $server.Connect()

    #
    # Try to find specified device
    #
    $deviceName = "HAImage1"
    $partnerTargetName = "iqn.2008-08.com.starwindsoftware:192.168.69.18-quorum"
    $deviceFound = $false
    
    foreach($device in $server.devices)
    {
        if ($device.name -eq $deviceName)
        {
            Write-Host "$($deviceName)" -foreground yellow
            Write-Host ""

            $deviceFound = $true
            $syncState = $device.GetPropertyValue("ha_synch_status")

            while ($syncState -ne "1")
            {
                #
                # Device not synchronized. Maybe it waiting for autosynchronization ?
                #
                $waitForAutoSync = $device.GetPropertyValue("ha_wait_on_autosynch")
                
                if ( $waitForAutoSync -eq "1" )
                {
                    Write-Host "Waiting for autosynchronization..." -foreground yellow
                }
                else
                {
                    if ( $syncState -eq "2" )
                    {
                        #
                        # Device is synchronizing. Get synchronization percent and show it
                        #
                        $syncPercent = $device.GetPropertyValue("ha_synch_percent")
                        
                        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow
                    }
                    
                    if ( $syncState -eq "3" )
                    {
                        #
                        # Device not synchronized. Synchronize current node from partner
                        #
                        Write-Host "Device not synchronized. Synchronize current node from partner '$($partnerTargetName)'" -foreground yellow

                        $params = new-object -ComObject StarWindX.Parameters        
                        $params.AppendParam("deviceID",$device.DeviceId)
                        $params.AppendParam("partnetTargetName",$partnerTargetName)
                        
                        $server.ExecuteCommand( 0, "restoreHAPartnerNode", $params)
                        
                        #
                        # If you want to synchronize partners from current node you can comment out code above and uncomment section below
                        #
                        
                        #
                        # Device not synchronized. Mark current node as 'Synchronized'. 
                        # WARNING, Command changes Device Status to "Synchronized" without Data Synchronization with HA (High Availability) Partner, 
                        # Device will start processing Client Requests immediately and will be used as Data Synchronization Source for Partner Device.
                        #
                        
                        Write-Host "Device not synchronized. Mark current node as 'Synchronized'. " -foreground yellow

                        $params = new-object -ComObject StarWindX.Parameters        
                        $params.AppendParam("deviceID",$device.DeviceId)
                        
                        $server.ExecuteCommand( 0, "restoreCurrentHANode", $params)
                        
                        Start-Sleep -m 5000
                    }
                }

                #
                # Refresh device info
                #
                $device.Refresh()

                Start-Sleep -m 1000
                
                $syncState = $device.GetPropertyValue("ha_synch_status")
            }
            
            Write-Host "Synchronization Status: Synchronized" -foreground yellow 

            break;
        }
    }
    
    if ( $deviceFound -ne $true )
    {
        Write-Host "$($deviceName) not found" -foreground red
    }
}
catch
{
    Write-Host "Exception $($_.Exception.Message)" -foreground red 
}

$server.Disconnect( )
Returns the error:

Code: Select all

HAImage1

Device not synchronized. Synchronize current node from partner 'iqn.2008-08.com.starwindsoftware:192.168.69.18-quorum'
Exception Exception calling "ExecuteCommand" with "3" argument(s): "Error: 
200 Failed: connection with partner node is invalid.. "
I'm a little stumped, i'm sure it's something simple but i'm just not seeing it.

Thanks[/size][/i]
Ivan (staff)
Staff
Posts: 172
Joined: Thu Mar 09, 2017 6:30 pm

Wed May 24, 2017 5:09 pm

Hello dandockson,
Thanks for your interest in StarWind solution
Yes, as far as you can see in script examples #p1 is first node interfaces and #p2 is the second node interfaces
Post Reply