While I was working on the Oracle Databases on Web Scale Tech Note for Nutanix I needed a way to quickly add disks to my Oracle RAC VM’s and set the multi-writer flag at the same time. To do this I created a PowerCLI script. It’s quite simple in what it does, but it works, and met my requirements. In the process however I ran into a VMware bug as well. So in this article I’ll explain the bug, and include my script and how it works. You can use this to add disks to an Oracle RAC node and set the multi-writer flag.
Take a look at the Oracle Databases on Web-Scale Infrastructure Tech Note and you will see some of what I’ve been up to lately. Including vMotion of Monster Oracle RAC VM’s on the Nutanix platform. This document contains some of my secret source that I’ve used for tuning systems for over a decade. I’m working on another paper that goes into more depth and contains even more of the tuning secret source. I will let you know when that is available.
As I was going through the work for this paper I was building up a large Oracle RAC system of about 4TB in total size on 3 Oracle RAC 12c Nodes (8 vCPU, 112GB RAM each). I found that I couldn’t add a virtual disk to the Oracle RAC cluster while the VM’s are running. I was running all my tests on vSphere 5.5. I knew from previous experience that at one time this worked on previous releases. You were able to add disks to live running Oracle RAC clusters with the multi-writer flag before.
But in 5.5 this has changed and it is not possible to add a disk to a live running VM due to a change in the VIM API. If you attempt it the operation will fail complaining that the disk is locked. There is no KB article on this issue, although VMware Engineering / Support is aware of this problem. This is sort of a regression. But in some ways I think maybe it was an accident or unintended that it worked before and in 5.5 it’s been ‘fixed’.
Whatever the case the only solution at the moment is to add the disks to the nodes when they are offline. At least it can be done very quickly, especially when using PowerCLI. So your outage window will be very limited. Unfortunately as all the disks are shared that means all of the Oracle RAC Nodes need to be shut down at the same time. Compared to the benefits of virtualizing Oracle RAC this is a minor inconvenience. Hopefully VMware will fix this in an upcoming update, or that you aren’t using 5.5 yet for Oracle RAC (5.0 and 5.1 still work as far as I know, I haven’t tested the recent update releases though). Also don’t try and extend the disks of the running VM’s while they’re operational, that is also not supported and won’t work. If you’re using DNFS, or in guest storage access to another storage system these restrictions may not apply.
Here are the simple scripts that I mocked up to add the disks to my Oracle RAC nodes. These quite basic and I can think of lots of ways to improve them, including taking input for more than one operation at a time. But these are a start. If you choose to use them and improve upon them I’d be happy to hear about it and would like to add the improvements here. So please let me know how you get on. Please bare in mind that these scripts are without warranty of any kind and for use at your own risk and informational purposes only. I’m hoping in the future it’ll be easy to set a disk to multi-writer when it’s created through the New-HardDisk CmdLet, without using the VIM API. This would make the scripts significantly simpler.
Add New Disk to Oracle RAC Node with Multi-writer Flag set:
Connect-VIServer <YourvCenter>
$vmname = Read-Host “VM Name to add disks to”
$vmdk = Read-Host “Disk to Add (Full Path)”
[int]$busnumber = Read-host “SCSI Bus Number Number”
[int]$unitnumber = Read-Host “Disk Unit Number”
[int]$capacity = Read-Host “Disk Capacity (GB)”
$vm = Get-VM $vmname
[int64]$capcitykb = ($capacity * 1gb) / 1kb
Write-Host “Creating New Disk ” $vmdk ” of size ” $capacity ” GB to ” $vm ” at SCSI ID ” $busnumber “:” $unitnumber
Write-Host “Disk Capacity in KB ” $capcitykb
$ctrll = Get-ScsiController -VM $vm | ?{$_.extensiondata.busNumber -eq $busnumber}
Write-Host “Controller Key “$ctrll.extensiondata.key
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = “add”
$spec.deviceChange[0].fileOperation = “create”
$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk
$spec.deviceChange[0].device.key = -100
$spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo
$spec.deviceChange[0].device.backing.fileName = “”+$vmdk
$spec.deviceChange[0].device.backing.thinProvisioned = $false
$spec.deviceChange[0].device.backing.split = $false
$spec.deviceChange[0].device.backing.writeThrough = $false
$spec.deviceChange[0].device.backing.eagerlyScrub = $true
$spec.deviceChange[0].device.backing.diskMode = “independent_persistent”
$spec.deviceChange[0].device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$spec.deviceChange[0].device.connectable.startConnected = $true
$spec.deviceChange[0].device.connectable.allowGuestControl = $false
$spec.deviceChange[0].device.connectable.connected = $true
$spec.deviceChange[0].device.controllerKey = [int]$ctrll.extensiondata.key
$spec.deviceChange[0].device.unitNumber = [int]$unitNumber
$spec.deviceChange[0].device.capacityInKB = [int64]$capacitykb
$spec.extraConfig = New-Object VMware.Vim.OptionValue[] (1)
$spec.extraConfig[0] = New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = “scsi” + $busnumber + “:” + $unitnumber + “.sharing”
$spec.extraConfig[0].value = “multi-writer”
$vm.ExtensionData.ReconfigVM($spec)
Add Existing Disk to Oracle RAC Node with Multi-writer Flag Set:
Connect-VIServer <YourvCenterHere>
$vmname = Read-Host “VM Name to add disks to”
$vmdk = Read-Host “Disk to Add”
[int]$busnumber = Read-host “SCSI Bus Number Number”
[int]$unitnumber = Read-Host “Disk Unit Number”
$vm = Get-VM $vmname
Write-Host “Adding Disk “$vmdk” to “$vm” at SCSI ID “$busnumber”:”$unitnumber
$ctrll = Get-ScsiController -VM $vm | ?{$_.extensiondata.busNumber -eq $busnumber}
Write-Host “Controller Key “$ctrll.extensiondata.key
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = “add”
$spec.deviceChange[0].device = New-Object VMware.Vim.VirtualDisk
$spec.deviceChange[0].device.key = -100
$spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo
$spec.deviceChange[0].device.backing.fileName = “”+$vmdk
$spec.deviceChange[0].device.backing.diskMode = “independent_persistent”
$spec.deviceChange[0].device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$spec.deviceChange[0].device.connectable.startConnected = $true
$spec.deviceChange[0].device.connectable.allowGuestControl = $false
$spec.deviceChange[0].device.connectable.connected = $true
$spec.deviceChange[0].device.controllerKey = [int]$ctrll.extensiondata.Key
$spec.deviceChange[0].device.unitNumber = [int]$unitNumber
$spec.extraConfig = New-Object VMware.Vim.OptionValue[] (1)
$spec.extraConfig[0] = New-Object VMware.Vim.OptionValue
$spec.extraConfig[0].key = “scsi” + $busnumber + “:” + $unitnumber + “.sharing”
$spec.extraConfig[0].value = “multi-writer”
$vm.ExtensionData.ReconfigVM($spec)
Final Word
Hopefully these simple scripts will help you when creating net new Oracle RAC clusters on VMware vSphere and when adding disks to existing clusters. You can use them for your own purposes and modify them as you want. Additional information can be found on the VMware Business Critical Apps Blog.
—
This post first appeared on the Long White Virtual Clouds blog at longwhiteclouds.com. By Michael Webster +. Copyright © 2012 – 2014 – IT Solutions 2000 Ltd and Michael Webster +. All rights reserved. Not to be reproduced for commercial purposes without written permission.
Just ran into this but I disagree with "Compared to the benefits of virtualizing Oracle RAC this is a minor inconvenience." This would make this a non-starter for a production system as you lose your HA component just to add space.
There will apparently be a patch. It would mean you’d have to more carefully plan expansion. But adding disks doesn’t happen that often.
There is a VMware KB article about that: http://kb.vmware.com/kb/2078540
Thanks Martin. I wondered when there would be a KB created for this. Thanks for letting us know.
It looks like it's fixed in vSphere 5.5U2
Do you have any experience backing up oracle RAC VM? I believe VMware has a limitation to run a snapshot in a share disk with multi-driver enable.
Hi Mike, Yes you are correct. You can't really take a snapshot of the VM's using VMware based snapshots. However you can take storage based snapshots, or you can use RMAN. The preferred method is still to use Oracle RMAN integrated technologies. VMware doesn't yet recognise multi-writer disks or clusters with regard to their snapshot technology or other technologies including provisioning operations, storage vMotion etc.
Can confirm … ESXi 5.5 Patch 2 Build 1892794 brought back this functionality. VMSupport confirmed to me that its absence was indeed a bug.
Hi Lenny,
I haven’t installed Update 2 for ESXi 5.5 yet, but that is my understanding. This was a bug and has now been fixed. Next bug I’m trying to track down is running more than 26 ASM disks in one VM.
FYI — http://houseofbrick.com/esxi-5-5-multi-writer-bug/
That post is based off of the work they did for us on a PoC I am leading for Oracle RAC VMs.
Hi, I really wish I could find the above simple. Unfortunatley I don't (I really struggle with PowerShell in comparison to BASH).
Is there a simpler way than above? Say I already had the disks created, setup as independent etc. All I actually need to do is set the values:
scsi1:0.sharing = multi-writer
scsi1:1.sharing = multi-writer
for a VM named env-test
Can anyone help?
Hi Davros, You could also use the Perl SDK or one of the other VMware SDK\’s to achieve the same thing, but the PowerShell CommandLets are very powerful once you figure out how to use them. I\’ve also checked and this still doesn\’t work in vSphere 5.5 Update 2, even though the problem was meant to be fixed.
Thanks for the script Michael. BTW I was having an issue while running the first script with both vSphere 5.5 and 5.1 so thought of sharing my “quick fix” in case someone faces the same problem. I had to change the following line in order to get it working:
[int64]$capcitykb = ($capacity * 1gb) / 1kb
into this
[int64]$capcitykb = $capacity * 1048576
Not sure why but that did the trick for me.
Cheers.
[…] For those interested in Automating the Multiwriter VMDK flag, I have created a quick PowerCLI sample called configureMultiwriterVMDK.ps1 which demonstrates this new vSphere API. You will need to specify the name of the VM as well as the label of the VMDK in which you wish to enable the Multiwriter VMDK flag (e.g. Hard disk 2). Below is an example of running the script. If you wish to add a new VMDK and enable the Multiwriter flag all at once, you can reference my script and using the following PowerCLI sample provided by Michael Webster here. […]