Welcome to another episode of our Virtual SAN Troubleshooting series. In our last article we detailed guidelines and troubleshooting steps around the Virtual SAN networking requirement for layer 2 multicast. In today’s article we will show you how to quickly automate the modification of the Virtual SAN multicast group address in the event the need arises.
Requirements
- PowerCLI 5.8 release 1
– (Note: It is likely to work with PowerCLI version 5.5 or above however I just happened to have version 5.8 on my test system). - Microsoft .Net 2.0 or higher
Here is a one-line code example where we target a single host:
1 |
(Get-EsxCli -Server "192.168.100.1").vsan.network.ipv4.set(224.2.3.7,23457,vmk1,224.1.2.7,23457,7) |
In the example above, you can see it would is quite easy to just pop into the PowerCLI shell and paste the command (after modifying values to your choosing of course). Once you set the appropriate values, you can reuse this same command string for your other hosts as well. All you have to do is update the host IP following the -Server parameter (e.g. Change “192.168.100.1” to “192.168.100.2”).
The other values to modify are included in parenthesis at the end of the command string and need to remain in the following order:
agentmcaddr, agentmcport, interfacename, mastermcaddr, mastermcport, multicastttl
Notice I am using the Get-EsxCli cmdLet to modify this change. If you are not familiar with the Get-EsxCli cmdLet, head on over to the vSphere PowerCLI Reference and check it out. It is quite the powerful cmdLet.
Creating a loop
A very quick and easy method to modify multiple hosts is to simply create multiple copies of the one-line command string and simply modify the host IP address in each line as in the example below:
1 2 3 |
(Get-EsxCli -Server "192.168.100.1").vsan.network.ipv4.set(224.2.3.7,23457,vmk1,224.1.2.7,23457,7) (Get-EsxCli -Server "192.168.100.2").vsan.network.ipv4.set(224.2.3.7,23457,vmk1,224.1.2.7,23457,7) (Get-EsxCli -Server "192.168.100.3").vsan.network.ipv4.set(224.2.3.7,23457,vmk1,224.1.2.7,23457,7) |
If you have a large number of servers or need to introduce more logic for other tasks, a proper script may be more suited to your solution. In the example below we display how to run this command string on a multiple number of hosts using the PowerShell Foreach-Object cmdlet. I have left out the usual add-snapin statements that load the environment for ease of reading.
Check out the comments within the script for an explanation of each step.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# Assigning Variables (Modify these to suit your environment and needs) $vmhostlist = @("192.168.100.1","192.168.100.2","192.168.100.3") $vmhostuser = "root" $vmhostpw = "vmware" $agentmcaddr = "224.2.3.7" $agentmcport = "23457" $interfacename = "vmk1" $mastermcaddr = "224.1.2.7" $mastermcport = "12347" $multicastttl = "7" # Please do not modify below this line unless you wish to adjust the functionality of the script. # Begin for loop foreach ($vmhost in $vmhostlist) { # 1. Connect to host connect-viserver -server "$vmhost" -user $vmhostuser -password $vmhostpw -force > $null # 2. Use variable for $esxcli = Get-EsxCli -Server "$vmhost" # 3. List VSAN VMkernel multicast configuration $esxcli.vsan.network.list() # 4. Syntax to modify multicast settings $esxcli.vsan.network.ipv4.set($agentmcaddr,$agentmcport,$interfacename,$mastermcaddr,$mastermcport,$multicastttl) # 5. Validate changes to VSAN VMkernel multicast configuration -foreground yellow $esxcli.vsan.network.list() } # End for loop # 6. Disconnect PowerCLI session from all hosts disconnect-viserver * -confirm:$false |
There are other avenues to modifying the multicast group addresses for Virtual SAN hosts. This is one functional example but do not hesitate to use any option that suits your scenario and experience (Esxcli, RVC, PowerCLI, etc.).
Happy scripting!
Disclaimer: Actual code examples from this article may or may not be officially supported by VMware. Please validate supportability and attempt first in a test environment before attempting anything in a production setting.
Resources
Changing the multicast address used for a VMware Virtual SAN Cluster (2075451)
VMware vSphere 5.5 Documentation Center: vSphere PowerCLI Reference: Get-EsxCLI