vdswitch分布式虚拟交换机配置文件在存储中的位置

Have you ever wondered what those .dvsData folder is on some of your datastores ? Well in this article I will give some insight to them and what they are used for.
Firstly some information around a vDS switch. Each vDS switch has a UUID in the format : "6a de 0e 50 80 32 76 68-e0 72 fd 00 c3 23 52 92" (as an example). When you look inside a datastore you will sometimes (Will explain just now on when) a .dvsData folder. If you look in there you will see 1 or more of these numbers. Each number correspond to a vDS switch that is used by the ESXi host.
So some rules around these files :
  • The .dvsData folder is only created if you have a VM on that datastore that is attached to a vDS. Thus if there is only VM's that is attached to a vSwitch on a datastore there will not be a .dvsData folder. Also only the datastore that holds the .vmx config file will have the .dvsData folder.
  • Inside the .dvsData folder there is a UUID number for each vDS switch.
  • Inside the UUID folder is a smaller file that is a number. This number corresponds to the ethernetx.dvs.portId inside the .vmx file of a VM. Below we can see that ethernet0.dvs.portId=10.




    ethernet0.dvs.switchId = "6a de 0e 50 80 32 76 68-e0 72 fd 00 c3 23 52 92"
    ethernet0.dvs.portId = "10"
    ethernet0.dvs.portgroupId = "dvportgroup-208"
    ethernet0.dvs.connectionId = "177280995"
Now why is this file ("10") important ? It is needed by HA to restart the VM on another host. Certain information (Port state, MTU, run time packets stats) must be transferred to the new host when starting up the VM and this file has that information. In a vMotion of a VM this information is transferred as part of the copy to the other host.
There is some config files that also important:
  • /etc/vmware/ dvsdata.db
    • Updated by hostd every 5 min
    • Contains data for persistent vdPorts (vmkernel)
  • The smaller files ("10" in our case)
    • Updated with vdPort information every 5 min by hostd
    • Contains data for the VM's vNIC's that is attached to the vDS
-------------------------------------------------------------------------------------------------------------------
Comment: vDS:虚拟化分布交换机(Virtual Distributed Switch)

Virtual老薛翻译版:
    
       大家曾经有没有怀疑过在Datastore中的.dvsData是干嘛用的?这篇文章我将给出这些代表什么和它的作用。       首先是一些围绕 vDS switch的信息,每一个vDS switch都有一个 UUID:"6a de 0e 50 80 32 76 68-e0 72 fd 00 c3 23 52 92" (举例说明),你展开.dvsData 文件夹可以看到这些号码,每一串数字都对应一个vDS switch,可以被ESXi所使用。       文件规则:
                        1. .dvsData文件只在Datastore中有VM使用到 vDS时才被创建,因此如果VM只绑定了普通vswitch的时候该文件夹不会出现, 也只有当Datastore中有 .vmx config文件的时候.dvsData才会被创建
                        2. Datastore里边是每一个UUID number对应相应的
vDS switch.为一个文件夹
                        3.UUID 文件夹里边是一个以数字命名的小文件,这个数字对应.vmx config文件里的ethernetx.dvs.portId项,这个小文件名是10则 ethernet0.dvs.portId=10 下面是我Virtual老薛自己的截图:


大家可以看到 dvs.portId 号码对应了虚拟交换机上面的端口号



为什么这个dvs.portId很重要?因为HA在其他机器上面启动的时候需要这个文件(vDS的发明主要作用就是为了统一管理虚拟网络交换机,如果交换机的配置不一样HA是切换不过来的),启动的时候Port state, MTU, run time packets stats需要被传输到新的ESXi主机上,vMotion同理
配置文件保存在系统的:/etc/vmware/ dvsdata.db 每5分钟会被Host更新一次