Page 1 of 1

Powershell questions

Posted: Tue Jan 23, 2018 10:52 am
by Davis
Hi all,

I'm trying to test 2-node Hyper-V 2012 R2 cluster with SW vSAN Free.
Without SW console.
I have several problems:

1. I cannot create HA imagefile device with sector size 4096. This parameter just ignored. And device gets 512 bytes sector.

Code: Select all

Import-Module StarWindX

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

	$server.Connect()

	$firstNode = new-Object Node

	$firstNode.HostName = "testcluster1"
	$firstNode.ImagePath = "My computer\E\Storage1"
	$firstNode.ImageName = "Storage1"
	$firstNode.Size = 5000
	$firstNode.CreateImage = $true
	$firstNode.TargetAlias = "storage1"
	$firstNode.AutoSynch = $true
	$firstNode.SyncInterface = "#p2=192.168.12.2:3260"
	$firstNode.HBInterface = "#p2=192.168.11.2:3260"
	$firstNode.PoolName = "pool1"
	$firstNode.SyncSessionCount = 1
	$firstNode.ALUAOptimized = $true
    $firstNode.CacheSize = 128
    $firstNode.CacheMode = "wb"
    
	#
	# 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 = new-Object Node

	$secondNode.HostName = "testcluster2"
	$secondNode.HostPort = "3261"
	$secondNode.Login = "root"
	$secondNode.Password = "starwind"
	$secondNode.ImagePath = "My computer\E\Storage1"
	$secondNode.ImageName = "Storage1"
	$secondNode.Size = 5000
	$secondNode.CreateImage = $true
	$secondNode.TargetAlias = "storage1"
	$secondNode.AutoSynch = $true
	$secondNode.SyncInterface = "#p1=192.168.12.1:3260"
	$secondNode.HBInterface = "#p1=192.168.11.1:3260"
	$secondNode.SyncSessionCount = 1
	$secondNode.ALUAOptimized = $true
        
	$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -initMethod "clear"
	while ($device.SyncStatus -ne [SwHaSyncStatus]::SW_HA_SYNC_STATUS_SYNC)
	{
		$syncPercent = $device.GetPropertyValue("ha_synch_percent")
	        Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow

		Start-Sleep -m 2000

        	$device.Refresh()
	}
}
catch
{
	Write-Host $_ -foreground red 
}
finally
{
	$server.Disconnect()
}
2. How should I correctly remove device+HA+target? Seems like I had many problems last days because did not remove test devices entirely. There were strange phantom HAImages after reboot, etc. Until I look into starwind.cgf file and see pieces of old devices.
Is sequence

Code: Select all

Remove-Device "imagefile1"
Remove-Device "HAImage1"
Remove-Target 
OK?

3. MPIO enabled, and it worked before, when I tested via GUI.
One HAdevice. iSCSI targets connected, one to 127.0.0.1, second to partner's target via heartbeat channel 192.168.11.0.
iScsiDiscoveryListInterfaces set to 1 on both nodes.
But now after I create device via Powershell I cannot set MPIO policy because there is only one path listed in "Device details" per iSCSI target. And I see two identical disk devices in disk management instead of single disk.
I've tried to solve this several days.
Today I've rebooted whole system after device creation and connection. And suddenly I've got two paths! And at last I can set MPIO policy.
Is it necessary to reboot system when work via powershell in this case?

But something is still wrong. MPIO does not work yet.
In iscscpl-Targets-select_local_target-Devices I see two disks instead of one and still have two disk copies in disk management
What do I do wrong?

Re: Powershell questions

Posted: Tue Jan 23, 2018 10:05 pm
by Boris (staff)
I cannot create HA imagefile device with sector size 4096. This parameter just ignored. And device gets 512 bytes sector.
How do you check this? In what way do you get the 512 bytes result?
How should I correctly remove device+HA+target?

Code: Select all

Remove-Device "HAImage1"
Remove-Device "imagefile1"
Remove-Target
The above should be a better solution, as it is the reversed procedure to the one that is followed when an HA is created.
But something is still wrong. MPIO does not work yet.
Have you enabled "Add support for iSCSI devices" from the multipath control panel?

Re: Powershell questions

Posted: Wed Jan 24, 2018 8:29 am
by Davis
Thank you for attention!
Boris (staff) wrote: How do you check this? In what way do you get the 512 bytes result?
Via Powershell, enum devices. Device object has SectorSize property.

Code: Select all

Remove-Device "HAImage1"
Remove-Device "imagefile1"
Remove-Target
The above should be a better solution, as it is the reversed procedure to the one that is followed when an HA is created.c
Seems like I did exactly this way and got undeleted HA devices in StarWind.cfg. I'll check again.
Have you enabled "Add support for iSCSI devices" from the multipath control panel?
Sure, yes.
Can it help if I attach screenshots?

Re: Powershell questions

Posted: Wed Jan 24, 2018 11:30 am
by Boris (staff)
enum devices. Device object has SectorSize property.
I tested both variants and do not confirm the behavior described by you. I was able to create disks with both 4096 and 512 bytes sector size. I used the standard script with storage files path, network interfaces and sector size being modified. All runs of the script with different parameters for the sector size produced expected results. Below is my script I used for testing.

Code: Select all

#Import-Module StarWindX

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

    $server.Connect()

    $firstNode = new-Object Node

    $firstNode.ImagePath = "My computer\D"
    $firstNode.ImageName = "masterImg123"
    $firstNode.Size = 256
    $firstNode.CreateImage = $true
    $firstNode.TargetAlias = "targetha123"
    $firstNode.AutoSynch = $true
    $firstNode.SyncInterface = "#p2=172.16.20.22:3260,172.16.21.2:3260"
    $firstNode.HBInterface = "#p2=172.16.10.22:3260,172.16.11.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 = "050176c0b535403ba3ce02102e33eab" 
    
    $secondNode = new-Object Node

    $secondNode.HostName = "192.168.0.85"
    $secondNode.HostPort = "3261"
    $secondNode.Login = "root"
    $secondNode.Password = "starwind"
    $secondNode.ImagePath = "My computer\D"
    $secondNode.ImageName = "partnerImg123"
    $secondNode.Size = 256
    $secondNode.CreateImage = $true
    $secondNode.TargetAlias = "partnerha123"
    $secondNode.AutoSynch = $true
    $secondNode.SyncInterface = "#p1=172.16.20.21:3260,172.16.21.1:3260"
    $secondNode.HBInterface = "#p1=172.16.10.21:3260,172.16.11.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()
Can it help if I attach screenshots?
It might be a good idea to do so. Could you publish them?

Re: Powershell questions

Posted: Wed Jan 24, 2018 11:43 am
by Davis
This is VERY strange.
Unfortunately I was not correct in first post.
Now I'm testing in Win server 2016 in virtual systems.

2012 R2 is "production" system. I did not test Powershell on it yet.
Moreover in 2016 I see different behaviour via powershell in GUI in several aspects.
I'll give you logs and screenshots soon.

Re: Powershell questions

Posted: Wed Jan 24, 2018 1:10 pm
by Boris (staff)
Fine, waiting for that.

Re: Powershell questions

Posted: Wed Jan 24, 2018 1:21 pm
by Davis
So, I've attached scripts and log files to this message and placed images here http://dropmefiles.com/wNr7w as this forum don't want to accept 1MB file.

What I did:
removed all devices, restart Starwind service,
run my CreateHA2 script to create Storage1 device, connected iSCSI,
created Storage2GUI device via SW console with same parameters as in script, connected iSCSI.

In result: GUI created device works fine.
Script created device:
1. Has Sector Size 512 instead of 4096
2. Connected to Windows as two devices instead of single multipath device.

Trying to fix these problems, comparing these devices, I found more stranges:
3. GUI device has same Serial Id for HAimage2, imagefile2 devices on first and HAimage2 device on second node. imagefile2 on second node has different ID. If serial did not specified in script then all four devices will have different IDs. I have specified ID in script for BOTH nodes and got this ID assigned to both HA devices, but imagefile devices got different IDs.
4. When script defines cache parameters only for first node as is by default, then partner's device created without cache. I have set cache parameters for both nodes in script to get both devices with same cache parameters.

I hope this info will help to sort out problems

UPD. I've attached swdsk files of both devices from first node. As I can see in comparison:
5. Script created device does not have this

Code: Select all

<parameters>
   <asyncmode>yes</asyncmode>
</parameters>
while GUI device has.

Re: Powershell questions

Posted: Wed Jan 24, 2018 2:46 pm
by Boris (staff)
I have checked the script with the build that you used and it did not work for me either in terms of sector size. I have escalated this to the developers. I expect it to be fixed in the next build.

Re: Powershell questions

Posted: Wed Jan 24, 2018 4:57 pm
by Davis
Boris (staff) wrote:in terms of sector size
Great!
And what about MPIO?
And did you see my update of that post?

Re: Powershell questions

Posted: Wed Jan 24, 2018 9:17 pm
by Boris (staff)
I have noticed the update. That has been transferred to the developers as well. I think that will be fixed, too.
As for MPIO, everything looks just fine, except for one thing that is not show in the screenshots. When you connect an iSCSI target in the Microsoft iSCSI Initiator, by default the below option is not enabled, while in your case it should be. Make sure you ticket it when connecting the targets. If not, delete the targets from the Favorites tab the reconnect all targets properly, keeping in mind that tricky tick.

Re: Powershell questions

Posted: Thu Jan 25, 2018 10:37 am
by Davis
Boris, thank you for note.
I select this item always.
I've created and connected both HA devices equally with one difference - creation method: powershell in one case and SW console in another.
Of course I've made iSCSI connections also same way ;)

BTW one minor thing I forget to tell.
Initially my direct-connected interfaces had a mask of 255.255.255.248.
But then I've saw output of command:

Code: Select all

>$server.Targets[0].Devices[0].Partners[0].HeartbeatChannels

IPAddress    Port SubnetMask    MACAddress
---------    ---- ----------    ----------
192.168.11.1 3260 255.255.255.0   

It's a very strange to see here 255.255.255.0.
I've changed masks on these interfaces in Windows to 255.255.255.0 for a case, but this does not solve my initial two problems.
So I just want you know about this thing.

Re: Powershell questions

Posted: Fri Jan 26, 2018 9:05 am
by Boris (staff)
As you have been asked to submit a support case, we will deal with this, too, and update the community with the information about the reasons after everything is resolved.