VMware Cloud Community
davros1984
Contributor
Contributor
Jump to solution

Help! Simple command or example to enable multi-writer flag on a VM

Hi there,

I have been attempting to find a simple example where the scsix:x.sharing value can be set to multi-writer via the powercli.

2 disks have already been correctly setup and presented to a VM, however they need the multi-writer value set in the advanced VM properties.I would like to be able to do this using powercli so that an outage can be avoided.

I have found some crazy examples:

a)Setting Multi Writer Flag for Oracle RAC on vSphere without any downtime | Virtualize Business Criti...

b)http://longwhiteclouds.com/2014/06/16/gotcha-adding-disk-to-virtual-oracle-rac-cluster-with-vmware-m...

However, these are way over my head and far too complex for me to even interpret (I am more a BASH scripter than PowerShell). Here was a simple cmd I found to enable disk UUID presentation on a VM:

Get-AdvancedSetting -Entity ENV-DBonly-centos6.5-template -Name disk.EnableUUID  | Set-AdvancedSetting -Value 'TRUE'


Is there anything like that command to set the  multi-writer value on disks that already exist, where the scsi ID etc is already known. If not, can any of you help with this?

Using onyx, I was able to grab the following:

# ------- ReconfigVM_Task -------

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.changeVersion = "2014-10-07T15:18:57.765323Z"

$spec.extraConfig = New-Object VMware.Vim.OptionValue[] (55)

$spec.extraConfig[54] = New-Object VMware.Vim.OptionValue

$spec.extraConfig[54].key = "scsi1:0.sharing"

$spec.extraConfig[54].value = multi-writer

However... how could I run the above against a specific VM? If I ran it as is, I am certain it would fail.

Any replies would be much appreciated.

1 Solution

Accepted Solutions
Wh33ly
Hot Shot
Hot Shot
Jump to solution

I'm not sure why you are changing this setting, but if you're trying to access the disk from different servers don't forget to disable change block tracking and to create a "Thick provision Eager Zeroed" disk as "Independent  / Persistent" mode.

This way all changes are directly written to your disk so the other VM also can access these changes. If you don't disable this, by default changes are kept in a different file,  problem is that you change the multiwriter setting on the VMDK only, and not on the Change block tracking file. This gives some odd errors about machines not accessing disks etc.

You could use :

To create  a new key

get-vm VM12345| New-AdvancedSetting -Name "scsi1:1.sharing" -Value "multi-writer" –confirm:$false


To alter an existing key

get-vm VM12345|Get-AdvancedSetting -Name "scsi1:1.sharing"|Set-AdvancedSetting -Value "multi-writer" –confirm:$false


Or create a new and overwrite any existing by adding the force parameter

get-vm VM12345| New-AdvancedSetting -Name "scsi1:1.sharing" -Value "multi-writer" –confirm:$false -force

I use the script below to change the value beforehand on all scsi ID's on  1 virtual SCSI node to Multiwriter and disable Change block tracking

get-vm VM12345,VM12346|Get-AdvancedSetting -Name scsi1:1.ctkEnabled|Set-AdvancedSetting -Value false –confirm:$false

$vm = "VM12345"

foreach($x in (0..15)) {

new-advancedsetting -entity $vm -name "scsi1:$X.sharing" -value "multi-writer" -confirm:$false

new-advancedsetting -entity $vm -name "scsi1:$X.ctkEnabled" -value "false" -confirm:$false

}

View solution in original post

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this.

But note that the script doesn't check if the disk is of the correct type, nor that it is shared.

$vmName = "MyVM"

$hdName = "Hard disk 2"

$vm = Get-VM -Name $vmName

$hd = Get-HardDisk -VM $vm -Name $hdName

$ctrl = Get-ScsiController -HardDisk $hd

Get-AdvancedSetting -Entity $vm -Name "scsi$($ctrl.ExtensionData.BusNumber):$($hd.ExtensionData.UnitNumber).sharing" |

Set-AdvancedSetting -Value "multi-writer"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
davros1984
Contributor
Contributor
Jump to solution

Hi - thanks for that. I'll give it a try in the morning.

I have a feeling though that as of powercli 5.1 the get-advancedsetting cmdlet has been removed?

I guess where I really struggle with Powershell are entries such as "scsi$($ctrl.ExtensionData.BusNumber):$($hd.ExtensionData.UnitNumber).sharing" - specifically, understanding where you can even locate/find the attribute $ctrl.ExtensionData.BusNumber. I have no idea how I would work out that I need to call ExtensionData to get the BusNumber Smiley Wink
As I was saying, unlike Bash, powershell in my view is quite poorly documented.

If I was to run "get-help Get-AdvancedSetting -detailed" I would expect to see an inclusion/description for each and every possible extended attribute (if that makes sense).


Cheers.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik the Get-AdvancedSettings cmdlet i snot depreciated.

Perhaps you mean the Get-VMHostAdvancedConfiguration ?

I see your point concerning the documentation, more specifically the ExtensionData (and in a similar way the Get-View cmdlet).

In short, via the ExtensionData property you get access to a read-only copy of the actual vSphere object (as documented in the SDK Reference).

But, the ExtensionData is not a PowerShell thing, it is a PowerCLI addtion, to facilitate access to the vSphere objects.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Wh33ly
Hot Shot
Hot Shot
Jump to solution

I'm not sure why you are changing this setting, but if you're trying to access the disk from different servers don't forget to disable change block tracking and to create a "Thick provision Eager Zeroed" disk as "Independent  / Persistent" mode.

This way all changes are directly written to your disk so the other VM also can access these changes. If you don't disable this, by default changes are kept in a different file,  problem is that you change the multiwriter setting on the VMDK only, and not on the Change block tracking file. This gives some odd errors about machines not accessing disks etc.

You could use :

To create  a new key

get-vm VM12345| New-AdvancedSetting -Name "scsi1:1.sharing" -Value "multi-writer" –confirm:$false


To alter an existing key

get-vm VM12345|Get-AdvancedSetting -Name "scsi1:1.sharing"|Set-AdvancedSetting -Value "multi-writer" –confirm:$false


Or create a new and overwrite any existing by adding the force parameter

get-vm VM12345| New-AdvancedSetting -Name "scsi1:1.sharing" -Value "multi-writer" –confirm:$false -force

I use the script below to change the value beforehand on all scsi ID's on  1 virtual SCSI node to Multiwriter and disable Change block tracking

get-vm VM12345,VM12346|Get-AdvancedSetting -Name scsi1:1.ctkEnabled|Set-AdvancedSetting -Value false –confirm:$false

$vm = "VM12345"

foreach($x in (0..15)) {

new-advancedsetting -entity $vm -name "scsi1:$X.sharing" -value "multi-writer" -confirm:$false

new-advancedsetting -entity $vm -name "scsi1:$X.ctkEnabled" -value "false" -confirm:$false

}

Reply
0 Kudos
davros1984
Contributor
Contributor
Jump to solution

Hi again,

Thanks for the update and appreciate the feedback/suggestion. I tried the command you provided, unfortunately it didn't work as the advanced setting doesn't currently exist. I.e. say the scsi number of the disk is 1:1.

When running: Get-AdvancedSetting -Entity $vm -Name "scsi$($ctrl.ExtensionData.BusNumber) -because this value isn't defined or has no value it doesn't return anything, thus I'm guessing that's why the "set" piece doesn't work.

When running cmd:get-advancedSetting -Entity $vmName -Name scsi*

The following is seen:

Name             Value            Type             Description
----             -----            ----             -----------
scsi0.pciSlotNumber  192              VM
scsi0.sasWWID    50 05 05 6c 53 09... VM
scsi1:0.sharing  multi-writer     VM

I had manually set it for the 1:0 disk, so that command executes OK, but not for disk 1:1.

I'll now look into the latest entry - cheers for your help again.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Like I said, my script didn't do any checking.

But this can be done in a Try-Catch construct, like this

$vmName = "MyVM"

$hdName = "Hard disk 2"

$vm = Get-VM -Name $vmName

$hd = Get-HardDisk -VM $vm -Name $hdName

$ctrl = Get-ScsiController -HardDisk $hd

Try {

    Get-AdvancedSetting -Entity $vm -Name "scsi$($ctrl.ExtensionData.BusNumber):$($hd.ExtensionData.UnitNumber).sharing" -ErrorAction Stop |

    Set-AdvancedSetting -Value "multi-writer"

}

Catch {

    New-AdvancedSetting -Entity $vm -Name "scsi$($ctrl.ExtensionData.BusNumber):$($hd.ExtensionData.UnitNumber).sharing"

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

davros1984
Contributor
Contributor
Jump to solution

Hi there,

The main reason for changing this setting is to use ASM disks for Oracle, see this pdf:http://www.vmware.com/files/pdf/solutions/oracle/Oracle_Databases_VMware_RAC_Deployment_Guide.pdf

Note: They do not mention altering the change block tracking value in that PDF. One thing I've also had to do to get the UUID of the disk presented (for udev rules to map disks to asm mount points) is this:

Get-AdvancedSetting -Entity $vmName -Name disk.EnableUUID  | Set-AdvancedSetting -Value 'TRUE'

I'll give what you said a go and report back. Thanks for making the time to reply - its appreciated!

Reply
0 Kudos
Wh33ly
Hot Shot
Hot Shot
Jump to solution

I used it to made a linux cluster where 2 nodes should have access to the same disk and can do IO on it.

Might not be needed for your Oracle design then as ASM probably needs a link to the voting disk.

But better check it before then when it's too late, I also would like to recommend to test all possible fail-over options. To make sure it's error free and without surprises when running the the Oracle cluster in a production environment. Might also be useful to do some simple administration tasks, like extending disks, adding disks etc. Again to be sure you won't get any surprises....

By testing a lot we found out about the change block tracking stuff. Multi-writer removes the lock on the .VMDK but not on the .ctk file. Might not be needed in your case but just an advice to do some proper tests Smiley Happy

btw..

You get errors like in this thread; disks cannot be opened or are locked etc.Oracle RAC with SRM 5.1

When checking VMware KB: Enabling or disabling simultaneous write protection provided by VMFS using the multi-writ...

It mentions "Changed Block Tracking (CBT)" as unsupported!


I'm a bit confused now what the proper settings will be for your Oracle Rac design, as it isn't clearly mentioned somewhere.

My guess still is that it should be disabled.

davros1984
Contributor
Contributor
Jump to solution

Hi,

Your commands and examples worked brilliantly. Thank you for sharing them.

Interesting point about the CBT bit, it makes sense to enable it based on that. I have had issues extending VMDK's used by ASM - I would not recommend it. I have found the cleanest approach to be:

1) Shutdown the VM's that utilise the ASM disks

2) Detach the ASM disks (at vSphere level) from all of the VM's that utilise them apart from 1 VM

3) On the 1 VM where the disks exist, expand them.

4) Power back on that VM - confirm all is well

5) Re-add them to the other VM's and verify all is well.

To me - the above is quite messy and avoids the point of using ASM Smiley Happy

It is much simpler to add a new disk of sufficient capacity and add it to your relevent ASM disk group. So the limitation there of course is the actual number of disks you present.

Wh33ly and LucD - thanks so much for your help. I wish other sources would make it simple to understand and follow like you both have.

Note: like the try and catch option - I am a big if, ifelse and else person in bash!

Cheers,

David.

Reply
0 Kudos