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()
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. "
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
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
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( )
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.. "
Thanks[/size][/i]