{"id":823,"date":"2017-08-23T06:55:14","date_gmt":"2017-08-23T04:55:14","guid":{"rendered":"https:\/\/www.em-soft.si\/myblog\/elvis\/?p=823"},"modified":"2017-08-23T06:55:14","modified_gmt":"2017-08-23T04:55:14","slug":"creating-vm-start-order-in-hyper-v-cluster-2016","status":"publish","type":"post","link":"https:\/\/em-soft.si\/myblog\/elvis\/?p=823","title":{"rendered":"Creating VM start order in Hyper-V Cluster 2016"},"content":{"rendered":"<p>Many times (or almost always), you have to define start order of VMs as services on one VM in an exactly defined order. We tried to solve this problem with start delays in the past \u2013 or with some additional software, but there were always situations where we are unable to control all factors.<br \/>\nNow in Windows Server 2016 edition it is better, as we can define startup groups. This means, that we define a group of servers who will start together and another group of servers who will start later when the first group is started or also with some delay after the first group is started. Additionally, we can start just a last group of servers and because this group depends on other groups, system will first start the parent server group. So, you are not able to start some servers before all infrastructure depends on it is started. We have new cmdlets in PowerShell to define and manage Cluster Groups (you can list them with<em><strong> Get-Command -Noun *ClusterGroup*<\/strong><\/em>).<\/p>\n<p><a href=\"https:\/\/em-soft.si\/myblog\/elvis\/?attachment_id=825\" rel=\"attachment wp-att-825\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-825\" src=\"https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_GetVMGroup.png\" alt=\"\" width=\"474\" height=\"265\" srcset=\"https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_GetVMGroup.png 474w, https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_GetVMGroup-300x168.png 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><br \/>\nTo do these settings, you have to know some concepts that are introduced in Windows Server 2016 and we will use them.<\/p>\n<ul>\n<li>This post explains how to create groups in Hyper-V cluster; it will not work on non-clustered servers. If you want to setup startup order for a single Hyper-V host, <a href=\"https:\/\/charbelnemnom.com\/2016\/05\/a-first-look-at-vm-groups-and-vm-start-ordering-in-windows-server-2016-hyper-v-hyperv-ws2016\/\">this is the post <\/a>where you can find how to do it.<\/li>\n<li>Cluster Group: Represents clustered services or applications (resource groups) in a failover cluster \u2013 any HA VM has his group. You can view cluster groups with PowerShell cmdlet<em><strong> Get-ClusterGroup<\/strong><\/em>. You don\u2019t need to change anything here; just leave them as they are.<\/li>\n<li>Cluster Group Set: Is a set of Cluster groups (VMs) that we want to control together. This is a set of VMs that have similar services and we want to control them as a group. Here we can control some settings (startup delay, global or local, \u2026). Cmdlet we have to use at this point is <em><strong>Set-ClusterGroupSet<\/strong> <\/em>(<a href=\"https:\/\/technet.microsoft.com\/en-us\/itpro\/powershell\/windows\/failoverclusters\/set-clustergroupset\">cmdlet syntax<\/a>)<\/li>\n<li>Cluster group set dependency: Is a dependency where we specify which group and when it will start. To be clear, with dependency we define VM startup order.<\/li>\n<\/ul>\n<p><strong>How to setup environment?<\/strong><br \/>\nI always start creating output with cmdlet Get-ClusterGroup, because it is easier to manage all VMs when I have all their names on a paper or TXT file. It is easier to review them, define services that they offer and later functionally define group sets.<br \/>\nWhen you have defined group sets (put VMs with similar services or dependencies together) it is time to create Cluster Group Sets. This operation is done in few steps:<\/p>\n<ul>\n<li>Create Cluster Group Set: this will create an empty group for grouping VMs. To do this you have to use cmdlet <em><strong>New-ClusterGroupSet -Name GroupName<\/strong><\/em>.<\/li>\n<li>Add Cluster Groups (VMs) to sets. In this step, we will populate Cluster Group Sets with VMs \u2013 this mean that we will put together all VMs with similar services or VMs that we need to start at the same time. When Cluster Group Set will be asked to start, all VMs that are in it will be started. There is no dependency inside the Cluster Group Set and we have no chance to control the start order inside the group. If we think that some VMs need to start before other VMs, we need more than one Cluster Group Set. To add VM to Cluster Group Set we will use PowerShell cmdlet <em><strong>Add-ClusterGroupToSet -Name GroupName -Group ClusterGroupName<\/strong><\/em>. In this cmdlet, you have to change <em><strong>GroupName<\/strong><\/em> with your Cluster Group Set name and <em><strong>ClusterGroupName<\/strong> <\/em>with Cluster Group name (VM name \u2013 output in firs step). We have to repeat cmdlet for every single VM.<a href=\"https:\/\/em-soft.si\/myblog\/elvis\/?attachment_id=824\" rel=\"attachment wp-att-824\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-824 size-full\" src=\"https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_CreateSetAndAddVM.png\" alt=\"\" width=\"877\" height=\"219\" srcset=\"https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_CreateSetAndAddVM.png 877w, https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_CreateSetAndAddVM-300x75.png 300w, https:\/\/em-soft.si\/myblog\/elvis\/wp-content\/uploads\/2017\/08\/VMGroup_CreateSetAndAddVM-768x192.png 768w\" sizes=\"auto, (max-width: 877px) 100vw, 877px\" \/><\/a><\/li>\n<li>Create dependency between Cluster Group Sets: We have to use cmdlet <em><strong>Add-ClusterGroupDependency -Group GroupName -ProviderSet GroupDependsOn<\/strong><\/em>. <em><strong>GroupName<\/strong><\/em> is the name of the Cluster Group Set we want to start and <em><strong>GroupDependsOn<\/strong><\/em> is a Cluster Group Set necessary to be started previously. At this point we need to create startup order (dependency) between groups. The start of any group can depend on successful start of one or more groups. If previous group will fail to start, the group who depends on it will not start. I suggest you to have in mind this situation (maybe develop a script to add and remove all VMs from groups \u2013 you will quickly solve problems if they appear).<\/li>\n<\/ul>\n<p>With this few steps, we created a startup order for our environment. If it is all OK, we will never have a situation when a service will not work because some dependency server is not started. Practically, the system will look to start all VMs in a defined order. This also means, that we have to add and remove depreciated and newly deployed VMs in this groups \u2013 we have to change this mechanism every single time we change our environment. Don\u2019t forget it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many times (or almost always), you have to define start order of VMs as services on one VM in an exactly defined order. We tried to solve this problem with start delays in the past \u2013 or with some additional software, but there were always situations where we are unable to control all factors. Now [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,12,15],"tags":[19,41,40],"class_list":["post-823","post","type-post","status-publish","format-standard","hentry","category-powershell","category-virtualization","category-windows-server","tag-hyper-v","tag-powershell","tag-windows-server"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts\/823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=823"}],"version-history":[{"count":1,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts\/823\/revisions"}],"predecessor-version":[{"id":826,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=\/wp\/v2\/posts\/823\/revisions\/826"}],"wp:attachment":[{"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/em-soft.si\/myblog\/elvis\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}