Page 1 of 1
Create HA target using Powershell
Posted: Fri Oct 03, 2014 4:38 am
by starwinduser
There is complete lack of documentation in using StarWind powershell module.
Im getting very informative error when creating HA target:
Exception Exception calling "CreateDevice" with "4" argument(s): "Error:
200 Failed: operation cannot be completed.. "
I suppose node.Size parameter in GB and node.CacheSize in MB?
Code: Select all
try
{
$server = New-SWServer -host 172.17.4.4 -port 3261 -user root -password starwind
$server.Connect()
$firstNode = new-Object Node
$firstNode.ImagePath = "My computer\C\CLUSTER\QUORUM\"
$firstNode.ImageName = "QuorumComp4"
$firstNode.Size = 24
$firstNode.CreateImage = $true
$firstNode.TargetAlias = "quorum4"
$firstNode.AutoSynch = $true
$firstNode.SyncInterface = "#p2=172.17.4.4:3260"
$firstNode.HBInterface = "#p2=192.168.203.4:3260"
$firstNode.CacheSize = 64
$firstNode.CacheMode = "wb"
$firstNode.PoolName = "pool1"
$firstNode.SyncSessionCount = 1
$firstNode.ALUAOptimized = $true
$secondNode = new-Object Node
$secondNode.HostName = "172.17.5.5"
$secondNode.HostPort = "3261"
$secondNode.Login = "root"
$secondNode.Password = "starwind"
$secondNode.ImagePath = "My computer\C\CLUSTER\QUORUM\"
$secondNode.ImageName = "QuorumComp5"
$secondNode.Size = 24
$secondNode.CreateImage = $true
$secondNode.TargetAlias = "quorum5"
$secondNode.AutoSynch = $true
$secondNode.SyncInterface = "#p1=172.17.5.5:3260"
$secondNode.HBInterface = "#p1=192.168.203.5:3260"
$secondNode.ALUAOptimized = $true
$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
}
$server.Disconnect()
Re: Create HA target using Powershell
Posted: Fri Oct 03, 2014 1:49 pm
by Anatoly (staff)
Hi!
First of all I`d like to apologize for the lack of documentation. We are working on get it ready.
Currently you can use
get-help. PoSh command to get help information.
In your case it is possible to run one of the following commands:
or
Please take into account that
size is using megabytes by default.
Also we suspect that there is missocnfiguration on the interfaces. If we understound correctly, here is how it should be configured:
Code: Select all
$firstNode.SyncInterface = "#p2=172.17.5.5:3260"
$firstNode.HBInterface = "#p2=192.168.203.5:3260"
...
$secondNode.SyncInterface = "#p1=172.17.4.4:3260"
$secondNode.HBInterface = "#p1=192.168.203.4:3260"
I hope that makes sense.
Re: Create HA target using Powershell
Posted: Fri Oct 03, 2014 4:34 pm
by starwinduser
I swapped nodes IP as you suggested but that didn't help. I created HA target manually using Management Console, but unfortunately I could not find Get-HADevice powershell function. Is there such a function?
Re: Create HA target using Powershell
Posted: Mon Oct 06, 2014 11:26 am
by Tarass (Staff)
Hi!
You can use the following code to get the list of devices and their properties:
Code: Select all
$server = New-SWServer -host XX.XX.XX.XX -user root -password starwind -port 3261
$server.Connect()
if ( $server.Connected )
{
write-host "Devices:"
foreach($device in $server.Devices)
{
$device
}
$server.Disconnect()
}
Or this one to get the list of device names only:
Code: Select all
$server = New-SWServer -host XX.XX.XX.XX -user root -password starwind -port 3261
$server.Connect()
if ( $server.Connected )
{
write-host "Devices:"
foreach($device in $server.Devices)
{
$device.name
}
$server.Disconnect()
}
Let me know if it does not work for you.
Re: Create HA target using Powershell
Posted: Mon Oct 06, 2014 1:51 pm
by Tarass (Staff)
Hi again,
In order to create an HA target you need to use the script like in sample below. Please take notes below the code into account, otherwise you will continue getting errors:
Code: Select all
Import-Module StarWindX
try
{
$server = New-SWServer -host XX.XX.XX.XX -port 3261 -user root -password starwind
$server.Connect()
$firstNode = new-Object Node
$firstNode.ImagePath = "My computer\S"
$firstNode.ImageName = "masterImg1"
$firstNode.Size = 256
$firstNode.CreateImage = $true
$firstNode.TargetAlias = "targetha1"
$firstNode.AutoSynch = $true
$firstNode.SyncInterface = "#p2=XX.XX.XX.XX:3260"
$firstNode.HBInterface = "#p2=XX.XX.XX.XX:3260"
$firstNode.CacheSize = 64
$firstNode.CacheMode = "wb"
$firstNode.PoolName = "pool1"
$firstNode.SyncSessionCount = 1
$firstNode.ALUAOptimized = $true
$secondNode = new-Object Node
$secondNode.HostName = "XX.XX.XX.XX"
$secondNode.HostPort = "3261"
$secondNode.Login = "root"
$secondNode.Password = "starwind"
$secondNode.ImagePath = "My computer\S"
$secondNode.ImageName = "partnerImg1"
$secondNode.Size = 256
$secondNode.CreateImage = $true
$secondNode.TargetAlias = "partnerha1"
$secondNode.AutoSynch = $true
$secondNode.SyncInterface = "#p1=XX.XX.XX.XX:3260"
$secondNode.HBInterface = "#p1=XX.XX.XX.XX:3260"
$secondNode.ALUAOptimized = $true
$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
}
$server.Disconnect()
Notes:
- sync and HB interfaces should be not partner server ip's, but the ip's of the node you are editing
- ImagePath should not contain trailing slash
- ImageName should not contain extension
- TargetAlias should not contain capital letters
Let me know about the result.
Re: Create HA target using Powershell
Posted: Mon Oct 06, 2014 8:41 pm
by starwinduser
finally I made it work by
setting sync and HB interfaces to partner server ip, and
setting same target alias name for both nodes
Code: Select all
try
{
$server = New-SWServer -host 172.17.4.4 -port 3261 -user root -password starwind
$server.Connect()
$firstNode = new-Object Node
$firstNode.ImagePath = "My computer\C\CLUSTER\QUORUM"
$firstNode.ImageName = "quorum"
$firstNode.Size = 1024
$firstNode.CreateImage = $true
$firstNode.TargetAlias = "quorum"
$firstNode.AutoSynch = $true
$firstNode.SyncInterface = "#p2=172.17.5.5:3260"
$firstNode.HBInterface = "#p2=192.168.203.5:3260"
$firstNode.CacheSize = 64
$firstNode.CacheMode = "none"
$firstNode.PoolName = "poolquorum"
$firstNode.SyncSessionCount = 1
$firstNode.ALUAOptimized = $true
$secondNode = new-Object Node
$secondNode.HostName = "172.17.5.5"
$secondNode.HostPort = "3261"
$secondNode.Login = "root"
$secondNode.Password = "starwind"
$secondNode.ImagePath = "My computer\C\CLUSTER\QUORUM"
$secondNode.ImageName = "quorum"
$secondNode.Size = 1024
$secondNode.CreateImage = $true
$secondNode.TargetAlias = "quorum"
$secondNode.AutoSynch = $true
$secondNode.SyncInterface = "#p1=172.17.4.4:3260"
$secondNode.HBInterface = "#p1=192.168.203.4:3260"
$secondNode.ALUAOptimized = $true
$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "Clear"
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
}
Re: Create HA target using Powershell
Posted: Fri Oct 10, 2014 5:03 pm
by johnk
Happen to have powershell script for 3 nodes?
Re: Create HA target using Powershell
Posted: Fri Oct 10, 2014 7:27 pm
by johnk
Found an example
Code: Select all
Import-Module StarWindX
try
{
$server = New-SWServer -host 10.1.6.161 -port 3261 -user root -password starwind
$server.Connect()
$firstNode = new-Object Node
$firstNode.ImagePath = "My computer\C\hastorage4"
$firstNode.ImageName = "haimage4"
$firstNode.Size = 1024
$firstNode.CreateImage = $true
$firstNode.TargetAlias = "hatarget4"
$firstNode.AutoSynch = $true
$firstNode.SyncInterface = "#p2=172.16.110.2:3260;#p3=172.16.114.3:3260"
$firstNode.HBInterface = "#p2=172.16.1.2:3260;#p3=172.16.1.3:3260"
$firstNode.CacheSize = 1024
$firstNode.CacheMode = "wb"
$firstNode.PoolName = "pool1"
$firstNode.SyncSessionCount = 1
$firstNode.ALUAOptimized = $true
$secondNode = new-Object Node
$secondNode.HostName = "10.1.6.162"
$secondNode.HostPort = "3261"
$secondNode.Login = "root"
$secondNode.Password = "starwind"
$secondNode.ImagePath = "My computer\C\hastorage"
$secondNode.ImageName = "haimage4"
$secondNode.Size = 1024
$secondNode.CreateImage = $true
$secondNode.TargetAlias = "hatarget4"
$secondNode.AutoSynch = $true
$secondNode.SyncInterface = "#p1=172.16.110.1:3260;#p3=172.16.112.3:3260"
$secondNode.HBInterface = "#p1=172.16.1.1:3260;#p3=172.16.1.3:3260"
$secondNode.ALUAOptimized = $true
$thirdNode = new-Object Node
$thirdNode.HostName = "10.1.6.163"
$thirdNode.HostPort = "3261"
$thirdNode.Login = "root"
$thirdNode.Password = "starwind"
$thirdNode.ImagePath = "My computer\C\hastorage"
$thirdNode.ImageName = "haimage4"
$thirdNode.Size = 1024
$thirdNode.CreateImage = $true
$thirdNode.TargetAlias = "hatarget4"
$thirdNode.AutoSynch = $true
$thirdNode.SyncInterface = "#p1=172.16.114.1:3260;#p2=172.16.112.2:3260"
$thirdNode.HBInterface = "#p1=172.16.1.1:3260;#p2=172.16.1.2:3260"
$thirdNode.ALUAOptimized = $true
$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -thirdNode $thirdNode -initMethod "Clear"
}
catch
{
Write-Host "Exception $($_.Exception.Message)" -foreground red
}
$server.Disconnect()
However I get an error:
Exception Exception calling "CreateDevice" with "4" argument(s): "Error:
200 Failed: operation cannot be completed.. "
Any ideas how to correct this ?
Re: Create HA target using Powershell
Posted: Mon Oct 13, 2014 2:36 pm
by Tarass (Staff)
Hi!
Could you please provide your network diagram with ip adresses reserved for sync and heartbeat included. Thank you
Re: Create HA target using Powershell
Posted: Tue Oct 14, 2014 5:47 pm
by Tarass (Staff)
Hi John,
A quick recap on our conversation: we have succeeded adding a third node replica by specifying the correct name for Starwind .swdsk header file.
If you have any further findings regarding StarwindX PowerShell module, post them here or send an e-mail directly to support. Thank you
Re: Create HA target using Powershell
Posted: Tue May 30, 2017 5:16 am
by ivan@webcluster.com
Most likely you do not have the folder pre-created before you execute the command:
$firstNode.ImagePath = "My computer\C\hastorage4"
Make sure you have a folder called hastorage4 on the c:\ of your machine.
Re: Create HA target using Powershell
Posted: Wed May 31, 2017 6:16 pm
by Michael (staff)
You might be correct, it was resolved 2,5 years ago...