{"id":70,"date":"2011-07-24T13:13:13","date_gmt":"2011-07-24T12:13:13","guid":{"rendered":"http:\/\/virtualizedworlduk.wordpress.com\/?p=1"},"modified":"2011-07-24T13:13:13","modified_gmt":"2011-07-24T12:13:13","slug":"hello-world-2","status":"publish","type":"post","link":"https:\/\/www.virtualworlduk.co.uk\/wordp\/hello-world-2\/","title":{"rendered":"vSphere 4.1 &#8211; Changing Path Selection Policy in Bulk"},"content":{"rendered":"<p>If you are like me, you will have come across the requirement to change the Path Selection Policy in vSphere.\u00a0 For most people this is performed from the vSphere Client and requires you to select each lun for each datastore on each host and change the Path Selection Policy to either Fixed, Most Recently Used or Round Robin.<br \/>\nThis is fine to do through the GUI for a single datastore across only a couple of hosts but recently I had to go through and do this for over 30 datastores across at least 10 hosts&#8230; performing this task through the GUI method would have taken me a good couple of hours to complete.<\/p>\n<p>We had recently performed a firmware upgrade to our XIV Gen 2 unit which therefore allowed us to begin to take advantage of the VAAI features in vSphere (more information on this will follow).\u00a0 On our previous XIV firmware version, we were advised to have our Path Selection Policy configured for Fixed but under the new version, the advice was to switch over to the preferred method of Round Robin.<\/p>\n<p>I therefore performed a quick google and came across the article by the &#8216;VirtualServerGuy&#8217; (<a href=\"http:\/\/www.virtualserverguy.com\/blog\/2010\/9\/22\/modify-vsphere-path-selection-policy-in-bulk.html\">http:\/\/www.virtualserverguy.com\/blog\/2010\/9\/22\/modify-vsphere-path-selection-policy-in-bulk.html<\/a>) which explained how to perform this task in a simpler way.<\/p>\n<p>The details below are taken from that guide:<br \/>\nStart up the <strong>vSphere PowerCli<\/strong> &#8211; we have this installed on our vCenter server as we have scripts running to check for snapshots and path failures.<\/p>\n<p>1.\u00a0 Connect to your vCenter Server:<br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Connect-VIServer &lt;vCenterServerName&gt;<\/strong><\/p>\n<p>2.\u00a0\u00a0List all of the hosts and disks that are on the XiV array that are not set for RoundRobin:<\/p>\n<div><strong>Get-VMHost | Get-ScsiLun -LunType &#8220;disk&#8221; | where {$_.MultipathPolicy \u2013ne &#8220;RoundRobin&#8221; -and $_.model -like &#8220;*xiv*&#8221;}| format-table VMHost,CanonicalName,MultiPathPolicy \u2013autosize<\/strong><\/div>\n<div><\/div>\n<div>Here is some more information on this\u00a0one-liner:<\/div>\n<ul>\n<li>Get-VMHost &#8211; connects to each host under management by the vCenter server<\/li>\n<li>Get-ScsiLun &#8211; gets SCSI LUNs of type \u201cdisk\u201d (as opposed to a controller or something else) that have a MultiPath Policy that is <em>not<\/em> Round Robin and also have a model name that includes \u201cXIV\u201d in the name.<\/li>\n<li>format-table &#8211; dumps a table listing the ESX host, the name of the LUN, and the current policy to the screen<\/li>\n<\/ul>\n<p>The key thing\u00a0now is to go through and change all of the Luns identified in one go, so\u00a0instead of dumping a table to the screen, let\u2019s pipe the results to the command <strong>Set-ScsiLun -MultipathPolicy &#8220;RoundRobin&#8221;<\/strong> .<\/p>\n<p>The complete command is:<\/p>\n<p><strong>Get-VMHost | Get-ScsiLun -LunType &#8220;disk&#8221; | where {$_.MultipathPolicy \u2013ne &#8220;RoundRobin&#8221; -and $_.model -like &#8220;*xiv*&#8221;}| Set-ScsiLun -MultipathPolicy &#8220;RoundRobin&#8221;<\/strong><\/p>\n<p>If you want to run the command first to verify that it will do what you expect it to do, then add the -whatif entry to the end of the line.\u00a0 Once you are satisfied, remove the -whatif entry and the command will then make the changes.<\/p>\n<p>I believe that this method went through and performed the change to all of my hosts and all of the relevant Luns in around 10 minutes automatically instead of me spending around two hours manually performing the same task.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are like me, you will have come across the requirement to change the Path Selection Policy in vSphere.\u00a0 For most people this is performed from the vSphere Client and requires you to select each lun for each datastore on each host and change the Path Selection Policy to either Fixed, Most Recently Used or Round Robin. This is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-vmware"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":0,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}