8 Replies Latest reply on Dec 4, 2017 11:17 PM by Pilu1978

    Multiwriter Disk

    Pilu1978 Enthusiast

      Guys,

      I need help to add multiwriter disk shared between 2 oracle VM's in my environment (vSphere 6, U2) using powercli.

       

      They are so many posts on the internet on this but I am not able get success my requirement as mentioned below:

       

      if the VM's are hosting one database then 9 multiwriter disk need to be added and shared between to these 2 VM's on the below SCSIID:

       

      Hard Disk 2: SCSI0:1

      Hard Disk 3: SCSI0:2

      Hard Disk 4: SCSI0:3

      Hard Disk 5: SCSI0:4

      Hard Disk 6: SCSI0:5

      Hard Disk 7: SCSI0:6

      Hard Disk 8: SCSI0:7

      Hard Disk 9: SCSI0:8

      Hard Disk 10: SCSI0:9

       

      if the VM's are hosting two database then another set of 9 multiwriter disk need to be added to new scso controller and shared between to these 2 VM's on the below SCSIID:

       

      Hard Disk 11: SCSI1:1

      Hard Disk 12: SCSI1:2

      Hard Disk 13: SCSI1:3

      Hard Disk 14: SCSI1:4

      Hard Disk 15: SCSI1:5

      Hard Disk 16: SCSI1:6

      Hard Disk 17: SCSI1:7

      Hard Disk 18: SCSI1:8

      Hard Disk 19: SCSI1:9

       

      The VM's wiil be offline.

       

      Any help will be much appreciated.

        • 1. Re: Multiwriter Disk
          LucD Guru
          Community WarriorsUser ModeratorsvExpert

          Note that scsi0:7 and scsi1:7 are not possible.
          The device number 7 is reserved for the SCSI controller itself.

           

          How would you tackle that in your numbering scheme?
          Just skip x:7 and continue with x:8?

          • 2. Re: Multiwriter Disk
            Pilu1978 Enthusiast

            Thanks for your reply.

             

            yes in that case will skip x:7 and continue with x:8

            • 3. Re: Multiwriter Disk
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Try something like this

               

              $vmNames = 'VM1','VM2'

              $nrDB = 2

              $nrDisk= 9

              $diskSizeGB = 1

               

              $diskUnitNr = 1..15 | where{$_ -ne 7}

               

              $vm = Get-VM -Name $vmNames[0]

               

              $scsi = Get-ScsiController -VM $vm -Name 'SCSI controller 0'

              $scsiBus = $scsi.ExtensionData.BusNumber

              $scsiKey = $scsi.Key

               

              $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

              for($db = 1; $db -le $nrDB; $db++){

                  if($db -gt 1){

                      $scsiBus = $scsiBus + 1

                      $scsiKey = -(200 + $db)

                      $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                      $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                      $controller = New-Object VMware.Vim.ParaVirtualSCSIController

                      $controller.Key = $scsiKey

                      $controller.BusNumber = 1

                      $dev.Device = $controller

                      $spec.DeviceChange += $dev

                  }

               

                  for($hd = 1;$hd -le $nrDisk; $hd++){

                      $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                      $disk = New-Object VMware.Vim.VirtualDisk

                      $back = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

                      $back.FileName = ''

                      $back.ThinProvisioned = $true

                      $back.DiskMode = 'independent_persistent'

                      $disk.Key = -($db * 100 + $hd)

                      $disk.ControllerKey = $scsiKey

                      $disk.CapacityInKB = $diskSizeGB*1GB/1KB

                      $disk.UnitNumber = $diskUnitNr[$hd - 1]

                      $disk.Backing = $back

                      $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                      $dev.FileOperation = [VMware.Vim.VirtualDeviceConfigSpecFileOperation]::create

                      $dev.Device = $disk

                      $spec.DeviceChange += $dev

                      $extra = New-Object VMware.Vim.OptionValue

                      $extra.key = "scsi$($scsiBus):$($diskUnitNr[$hd - 1]).sharing"

                      $extra.Value = "multi-writer"

                      $spec.ExtraConfig += $extra

                  }

              }

               

              $vm.ExtensionData.ReconfigVM($spec)

               

              $hdNames = Get-VM -Name $vmNames[0] | Get-HardDisk | where{$_.Name -ne 'Hard disk 1'} | Select -ExpandProperty FileName

               

              $vm = Get-VM -Name $vmNames[1]

               

              $scsi = Get-ScsiController -VM $vm -Name 'SCSI controller 0'

              $scsiBus = $scsi.ExtensionData.BusNumber

              $scsiKey = $scsi.Key

               

              $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

              for($db = 1; $db -le $nrDB; $db++){

                  if($db -gt 1){

                      $scsiBus = $scsiBus + 1

                      $scsiKey = -(200 + $db)

                      $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                      $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                      $controller = New-Object VMware.Vim.ParaVirtualSCSIController

                      $controller.Key = $scsiKey

                      $controller.BusNumber = 1

                      $dev.Device = $controller

                      $spec.DeviceChange += $dev

                  }

               

                  for($hd = 1;$hd -le $nrDisk; $hd++){

                      $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                      $disk = New-Object VMware.Vim.VirtualDisk

                      $back = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

                      $back.FileName = $hdNames[($db - 1) * $nrDisk + ($hd - 1)]

                      $back.ThinProvisioned = $true

                      $back.DiskMode = 'independent_persistent'

                      $disk.Key = -($db * 100 + $hd)

                      $disk.ControllerKey = $scsiKey

                      $disk.UnitNumber = $diskUnitNr[$hd - 1]

                      $disk.Backing = $back

                      $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                      $dev.Device = $disk

                      $spec.DeviceChange += $dev

                      $extra = New-Object VMware.Vim.OptionValue

                      $extra.key = "scsi$($scsiBus):$($diskUnitNr[$hd - 1]).sharing"

                      $extra.Value = "multi-writer"

                      $spec.ExtraConfig += $extra

                  }

              }

               

              $vm.ExtensionData.ReconfigVM($spec)

               

              • 4. Re: Multiwriter Disk
                Pilu1978 Enthusiast

                Thanks a lot.

                 

                Just one query and forgot to mention that the format  of multi-writer vmdks will be eager zeroed thick.

                • 5. Re: Multiwriter Disk
                  LucD Guru
                  vExpertCommunity WarriorsUser Moderators

                  Try the following.

                  Note that I also used the Sharing (introduced in vSphere 6) property instead of the ExtraConfig for setting multi-writer.

                   

                  $vmNames = 'VM1','VM2'

                  $nrDB = 2

                  $nrDisk= 9

                  $diskSizeGB = 1

                   

                  $diskUnitNr = 1..15 | where{$_ -ne 7}

                   

                  $vm = Get-VM -Name $vmNames[0]

                   

                  $scsi = Get-ScsiController -VM $vm -Name 'SCSI controller 0'

                  $scsiBus = $scsi.ExtensionData.BusNumber

                  $scsiKey = $scsi.Key

                   

                  $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

                  for($db = 1; $db -le $nrDB; $db++){

                      if($db -gt 1){

                          $scsiBus = $scsiBus + 1

                          $scsiKey = -(200 + $db)

                          $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                          $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                          $controller = New-Object VMware.Vim.ParaVirtualSCSIController

                          $controller.Key = $scsiKey

                          $controller.BusNumber = 1

                          $dev.Device = $controller

                          $spec.DeviceChange += $dev

                      }

                   

                      for($hd = 1;$hd -le $nrDisk; $hd++){

                          $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                          $disk = New-Object VMware.Vim.VirtualDisk

                          $back = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

                          $back.FileName = ''

                          $back.ThinProvisioned = $true

                          $back.DiskMode = 'independent_persistent'

                          $back.EagerlyScrub = $true

                          $back.Sharing = [VMware.Vim.VirtualDiskSharing]::sharingMultiWriter

                          $disk.Key = -($db * 100 + $hd)

                          $disk.ControllerKey = $scsiKey

                          $disk.CapacityInKB = $diskSizeGB*1GB/1KB

                          $disk.UnitNumber = $diskUnitNr[$hd - 1]

                          $disk.Backing = $back

                          $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                          $dev.FileOperation = [VMware.Vim.VirtualDeviceConfigSpecFileOperation]::create

                          $dev.Device = $disk

                          $spec.DeviceChange += $dev

                      }

                  }

                   

                  $vm.ExtensionData.ReconfigVM($spec)

                   

                  $hdNames = Get-VM -Name $vmNames[0] | Get-HardDisk | where{$_.Name -ne 'Hard disk 1'} | Select -ExpandProperty FileName

                   

                  $vm = Get-VM -Name $vmNames[1]

                   

                  $scsi = Get-ScsiController -VM $vm -Name 'SCSI controller 0'

                  $scsiBus = $scsi.ExtensionData.BusNumber

                  $scsiKey = $scsi.Key

                   

                  $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

                  for($db = 1; $db -le $nrDB; $db++){

                      if($db -gt 1){

                          $scsiBus = $scsiBus + 1

                          $scsiKey = -(200 + $db)

                          $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                          $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                          $controller = New-Object VMware.Vim.ParaVirtualSCSIController

                          $controller.Key = $scsiKey

                          $controller.BusNumber = 1

                          $dev.Device = $controller

                          $spec.DeviceChange += $dev

                      }

                   

                      for($hd = 1;$hd -le $nrDisk; $hd++){

                          $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                          $disk = New-Object VMware.Vim.VirtualDisk

                          $back = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

                          $back.FileName = $hdNames[($db - 1) * $nrDisk + ($hd - 1)]

                          $back.ThinProvisioned = $true

                          $back.DiskMode = 'independent_persistent'

                          $back.EagerlyScrub = $true

                          $back.Sharing = [VMware.Vim.VirtualDiskSharing]::sharingMultiWriter

                          $disk.Key = -($db * 100 + $hd)

                          $disk.ControllerKey = $scsiKey

                          $disk.UnitNumber = $diskUnitNr[$hd - 1]

                          $disk.Backing = $back

                          $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                          $dev.Device = $disk

                          $spec.DeviceChange += $dev

                      }

                  }

                   

                  $vm.ExtensionData.ReconfigVM($spec)

                   

                  • 6. Re: Multiwriter Disk
                    Pilu1978 Enthusiast

                    Thanks a lot.

                     

                    It is working perfectly.

                     

                    One last thing. I would like to store each of these multiwriter vmdk on a dedicated datastore.

                    • 7. Re: Multiwriter Disk
                      LucD Guru
                      User ModeratorsvExpertCommunity Warriors

                      Try like this

                       

                      $vmNames = 'VM1','VM2'

                      $nrDB = 2

                      $nrDisk= 1

                      $diskSizeGB = 1

                      $dsName = 'OtherDS'

                       

                      $diskUnitNr = 1..15 | where{$_ -ne 7}

                       

                      $vm = Get-VM -Name $vmNames[0]

                       

                      $scsi = Get-ScsiController -VM $vm -Name 'SCSI controller 0'

                      $scsiBus = $scsi.ExtensionData.BusNumber

                      $scsiKey = $scsi.Key

                       

                      $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

                      for($db = 1; $db -le $nrDB; $db++){

                          if($db -gt 1){

                              $scsiBus = $scsiBus + 1

                              $scsiKey = -(200 + $db)

                              $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                              $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                              $controller = New-Object VMware.Vim.ParaVirtualSCSIController

                              $controller.Key = $scsiKey

                              $controller.BusNumber = 1

                              $dev.Device = $controller

                              $spec.DeviceChange += $dev

                          }

                       

                          for($hd = 1;$hd -le $nrDisk; $hd++){

                              $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                              $disk = New-Object VMware.Vim.VirtualDisk

                              $back = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

                              $back.FileName = "[$($dsName)]"

                              $back.ThinProvisioned = $true

                              $back.DiskMode = 'independent_persistent'

                              $back.EagerlyScrub = $true

                              $back.Sharing = [VMware.Vim.VirtualDiskSharing]::sharingMultiWriter

                              $disk.Key = -($db * 100 + $hd)

                              $disk.ControllerKey = $scsiKey

                              $disk.CapacityInKB = $diskSizeGB*1GB/1KB

                              $disk.UnitNumber = $diskUnitNr[$hd - 1]

                              $disk.Backing = $back

                              $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                              $dev.FileOperation = [VMware.Vim.VirtualDeviceConfigSpecFileOperation]::create

                              $dev.Device = $disk

                              $spec.DeviceChange += $dev

                          }

                      }

                       

                      $vm.ExtensionData.ReconfigVM($spec)

                       

                      $hdNames = Get-VM -Name $vmNames[0] | Get-HardDisk | where{$_.Name -ne 'Hard disk 1'} | Select -ExpandProperty FileName

                       

                      $vm = Get-VM -Name $vmNames[1]

                       

                      $scsi = Get-ScsiController -VM $vm -Name 'SCSI controller 0'

                      $scsiBus = $scsi.ExtensionData.BusNumber

                      $scsiKey = $scsi.Key

                       

                      $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

                      for($db = 1; $db -le $nrDB; $db++){

                          if($db -gt 1){

                              $scsiBus = $scsiBus + 1

                              $scsiKey = -(200 + $db)

                              $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                              $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                              $controller = New-Object VMware.Vim.ParaVirtualSCSIController

                              $controller.Key = $scsiKey

                              $controller.BusNumber = 1

                              $dev.Device = $controller

                              $spec.DeviceChange += $dev

                          }

                       

                          for($hd = 1;$hd -le $nrDisk; $hd++){

                              $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec

                              $disk = New-Object VMware.Vim.VirtualDisk

                              $back = New-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo

                              $back.FileName = $hdNames[($db - 1) * $nrDisk + ($hd - 1)]

                              $back.ThinProvisioned = $true

                              $back.DiskMode = 'independent_persistent'

                              $back.EagerlyScrub = $true

                              $back.Sharing = [VMware.Vim.VirtualDiskSharing]::sharingMultiWriter

                              $disk.Key = -($db * 100 + $hd)

                              $disk.ControllerKey = $scsiKey

                              $disk.UnitNumber = $diskUnitNr[$hd - 1]

                              $disk.Backing = $back

                              $dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::add

                              $dev.Device = $disk

                              $spec.DeviceChange += $dev

                          }

                      }

                       

                      $vm.ExtensionData.ReconfigVM($spec)

                       

                      • 8. Re: Multiwriter Disk
                        Pilu1978 Enthusiast

                        Thanks Lucd for all your help. Much appreciated.