XenServer网卡Bonding

在给XenServer配置网卡bonding时,需要在所有节点都添加到集群之后再进行,这也是来自Citrix的建议:“Citrix 

recommends never joining a host that already has a bond configured on it to a pool”。用XenCenter连接XenServer

集群,通过界面操作对网卡进行bonding是很easy的,而要自动化完成这个功能,可通过调用xe命令去完成,但需要

对一些概念有了解。


对于一个XenServer集群,各个节点看到的逻辑网络应该是一样,否则VM迁移后网络就会出问题。比如原来这个VM

连接的是A网桥,迁移到另外的节点后没有同样的这么一个A网桥,VM就会不知所措。


假设我需要分别对eth0和eth2做bonding,eth1和eth3做bonding,那么首先我要创建两个网络,分别为bond02和

bond13,脚本(这些脚本都只在master节点运行)如下:


bond02_uuid=`xe network-create name-label=bond02`

bond13_uuid=`xe network-create name-label=bond13`


然后获取到集群中所有节点的host uuid:


host_uuids=`xe host-list|grep uuid|awk '{print $5}'`


循环对每个节点做bonding:


for host_uuid in $(echo $host_uuids | awk '{print;}')

do

 

    # 获取到eth0和eth2 的pif uuid

    host_eth0_pif=`xe pif-list host-uuid=$host_uuid device=eth0|grep -E '^uuid'|awk '{print $5}'`
    host_eth2_pif=`xe pif-list host-uuid=$host_uuid device=eth2|grep -E '^uuid'|awk '{print $5}'`


     # 对eth0和eth2做bonding,这里的network-uuid就是上面创建网络bond02后返回的uuid,每个节点都用它

    xe bond-create network-uuid=$bond02_uuid pif-uuids=$host_eth0_pif,$host_eth2_pif mode=lacp


    # 获取到eth1和eth3 的pif uuid

    host_eth1_pif=`xe pif-list host-uuid=$host_uuid device=eth1|grep -E '^uuid'|awk '{print $5}'`
    host_eth3_pif=`xe pif-list host-uuid=$host_uuid device=eth3|grep -E '^uuid'|awk '{print $5}'`


   # 对eth1和eth3做bonding,这里的network-uuid就是上面创建网络bond13后返回的uuid,每个节点都用它

    xe bond-create network-uuid=$bond13_uuid pif-uuids=$host_eth1_pif,$host_eth3_pif mode=lacp


done


“xe bond-create”命令中我指定的mode是lacp,关于这个需要了解的可移步这里

posted @   顺哥聊数字化  阅读(1438)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示