VMware Cloud Community
Gmelo
Contributor
Contributor

Migracion de VMs atomatica sin DRS | Automatic VM migration without DRS

Una consulta

cuando un servidor se apaga por x o y razón y él HA subes esas VMs en otro nodo.

cuando el nodo que se apagado vuelve a estar disponible hay alguna configuración que no sea DRS que devuelva esa vm al host que se apagó?

when a server goes down for anyy reason and the HA move the VMs to another node.

when the node that was shut down becomes available again is there any non-DRS setting that returns that vm to the host that was shut down?

Reply
0 Kudos
13 Replies
NicolasAlauzet

Hi there,

Saddly the only way to achieve that is with DRS.

Maybe you can have a script that runs every x time that checks vm location and triggers a vmotion if not in Y host. But seems way more complex than the affinity rule.

-------------------------------------------------------------------
Triple VCIX (CMA-NV-DCV) | vExpert | MCSE | CCNA
Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

Only DRS provides the resource balancing that would result in automatic migrations after the return of a previously failed host.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
nachogonzalez
Commander
Commander

Hey, hope you are doing fine.
For automatic load balancing you depend on DRS / third party tools like Turbonomics
I've seen customers use a script to evacuate and migrate all vms when they want to put them into mainteniance mode.

Other than that, you are limited i think

Reply
0 Kudos
Gmelo
Contributor
Contributor

how i can get or create a script for that?

Reply
0 Kudos
nachogonzalez
Commander
Commander

This lines will trigger a vMotion to the desired destination.
You should toy arround with that in order to get that working.


Get-VM -Location “<sourcehost>” | Move-VM -Destination (Get-Vmhost “<destinationhost>”).

To evacuate all VMs should be easier

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

One issue with using a script is you would somehow need to know which VMs need moving back to the original host (based on your original question about a HA event) - any manual vMotion migrations would mean your script may no longer be valid.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
Gmelo
Contributor
Contributor

Do you have an example for the entry script?

Reply
0 Kudos
nachogonzalez
Commander
Commander

Unfortunately I don't currently

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

There is a dedicated forum area for PowerCLI, would you like this thread moving there?


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
Gmelo
Contributor
Contributor

Yess!

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

Moderator: Thread moved to the PowerCLI area.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

LucD

Any scripts up your sleeve that can migrate VMs back to their original host after it recovers from a HA event?


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
LucD
Leadership
Leadership

Not directly, the VM doesn't keep track of where it was before.

But one could look at the Events, provided they are kept long enough.

The following example snippet looks back 1 hour, but that can be adapted.
And then 'moves' the VM back to the ESXi node where it was before the last vMotion.
Provided there has been a vMotion during the last hour.

$event = Get-VIEvent -Entity $vm -Start (Get-Date).AddHours(-1) |

where{$_ -is [VMware.Vim.VmMigratedEvent]} |

Sort-Object -Property CreatedTime -Descending |

Select -First 1


if($event){

    Move-VM -VM $vm -Destination $event.SourceHost.Name

}


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

Reply
0 Kudos