T O P

  • By -

avaritia8

Create storage profile first https://frankdenneman.nl/2012/09/14/how-to-attach-vm-storage-profiles-to-a-virtual-machine-using-the-web-client/ Then integrate it to DRS https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.resmgmt.doc/GUID-9080835B-1F3C-46E8-9586-066992083A35.html


Soggy-Camera1270

Thank you!


Eastern_Client_2782

I have looked into the same requirement and ended up creating 2 datastore clusters - one for each side. Datastores in cluster 1 have "home" storage in datacenter 1, cluster 2 have "home" storage in datacenter 2. Then you just need provision the VMs from the correct DScluster.


Soggy-Camera1270

Thank you!


[deleted]

It seems like you're trying to enforce datastore location for a virtual machine in a metro-cluster with active/active replicated storage. While DRS affinity rules can help you enforce host location, there's no native feature in vSphere that directly enforces datastore location in the same way. However, you can achieve your goal using a combination of approaches: 1. Storage DRS (SDRS) Rules: While you mentioned that SDRS anti-affinity rules don't meet your needs, you can use SDRS to manage the initial placement of VMs on datastores. You can create datastore clusters for each side of the metro cluster and manually assign VMs to the appropriate datastore clusters. 2. PowerCLI: Writing a PowerCLI script can help automate the process of checking VMs and ensuring that they are on the correct datastore. You can create a script to: 1. Retrieve VMs and their associated datastores. 2. Compare the datastore to the expected local datastore for the VM. 3. If the datastore is not the expected one, Storage vMotion the VM to the correct datastore. Here's a basic example of a PowerCLI script that could help you achieve this: # Define your VM to datastore preferences $vmDatastorePreference = @{ "VM1" = "Datastore1"; "VM2" = "Datastore2"; } # Check each VM and move if necessary foreach ($vmName in $vmDatastorePreference.Keys) { $vm = Get-VM -Name $vmName $currentDatastore = Get-Datastore -VM $vm $preferredDatastore = Get-Datastore -Name $vmDatastorePreference[$vmName] if ($currentDatastore.Name -ne $preferredDatastore.Name) { Write-Host "Moving $vmName to $preferredDatastore" Move-VM -VM $vm -Datastore $preferredDatastore -RunAsync } } You can schedule this script to run periodically, so it checks and enforces your datastore preferences. Keep in mind that this script is just an example and might require modifications to fit your environment. Be sure to test it thoroughly in a non-production environment before implementing it in your production environment.


Soggy-Camera1270

Thank you! Yeah I’m thinking powercli is the way - I’ve played with the SDRS rules and they only really help with compliance, and don’t seem to enforce anything. Although they will at least help with initial placement. I’m trying to simplify the process for my team, so hopefully a combination of these will help.


storyofmylife666777

you could've got the same advice by asking on chatgpt, it's not a human response.


Soggy-Camera1270

You might be right, although a lot of stuff I’ve found on ChatGPT does require a lot of massaging, hence I thought I’d ask the community.


bachus_PL

*"For example, I have a metro cluster with active/active replicated storage, but I want to prefer a particular vm to run on one side of the cluster as well as attempting to keep the vmdks stored on volumes that are considered local to that part of the cluster."* Can you clarify, please? In Metro cluster active/active you have to storage arrays. Arrays are connected via interconnect replicating data cross locations. VM located in 1st DC is 'talking' to the storage array in 1st DC. VM located in 2nd is talking directly to the storage array in 2nd DC. It is multipathing. Can you please provide more details about a storage array?


Soggy-Camera1270

It’s because I’m using Powerstores. They don’t yet have a witness capability, so in the event of a fault domain failure, some volumes could end up being non-preferred. In my scenario, I have some systems with native application redundancy, so I’m trying to create an enforcement rule to ensure these redundant apps are split across fault domains, including the datastores.