4.2.6. linux_bond
定义将两个或多个 接口 接合在一起的 Linux 绑定。这有助于冗余,并增加带宽。确保在 bonding_options 参数中包含基于内核的绑定选项。
| 选项 | 默认 | 描述 |
|---|---|---|
| name | 绑定的名称。 | |
| use_dhcp | False | 使用 DHCP 获取 IP 地址。 |
| use_dhcpv6 | False | 使用 DHCP 获取 v6 IP 地址。 |
| addresses | 分配给绑定的 IP 地址列表。 | |
| Routes | 分配给绑定的路由列表。请参阅 第 4.2.7 节 “Routes”。 | |
| mtu | 1500 | 连接的最大传输单元(MTU)。 |
| 成员 | 要在绑定中使用的接口对象序列。 | |
| bonding_options |
创建绑定时的一组选项。请参阅 Linux bonds 的 | |
| defroute | True |
使用 DHCP 服务提供的默认路由。仅在启用 |
| persist_mapping | False | 编写设备别名配置而不是系统名称。 |
| dhclient_args | 无 | 要传递给 DHCP 客户端的参数。 |
| dns_servers | 无 | 要用于绑定的 DNS 服务器列表。 |
- Linux bonds 的
bonding_options参数 -
bonding_options参数为 Linux 绑定设置特定的绑定选项。请参阅以下表的 Linux 绑定示例:
bonding_options | 描述 |
|---|---|
|
|
设置绑定模式,在示例中为 |
|
| 定义 LACP 数据包是每 1 秒发送一次,或每 30 秒发送一次。 |
|
| 定义接口在用于流量前必须处于活跃状态的最短时间。这个最小配置有助于缓解端口中断。 |
|
| 使用驱动程序的 MIIMON 功能监控端口状态的时间间隔(毫秒)。 |
- 示例 - Linux 绑定
... edpm_network_config_template: | --- {% set mtu_list = [ctlplane_mtu] %} {% for network in nodeset_networks %} {{ mtu_list.append(lookup(vars, networks_lower[network] ~ _mtu)) }} {%- endfor %} {% set min_viable_mtu = mtu_list | max %} network_config: - type: linux_bond name: bond1 mtu: {{ min_viable_mtu }} bonding_options: "mode=802.3ad lacp_rate=fast updelay=1000 miimon=100 xmit_hash_policy=layer3+4" members: type: interface name: ens1f0 mtu: {{ min_viable_mtu }} primary: true type: interface name: ens1f1 mtu: {{ min_viable_mtu }} ...- 示例 - Linux bond:绑定两个接口
... edpm_network_config_template: | --- {% set mtu_list = [ctlplane_mtu] %} {% for network in nodeset_networks %} {{ mtu_list.append(lookup(vars, networks_lower[network] ~ _mtu)) }} {%- endfor %} {% set min_viable_mtu = mtu_list | max %} network_config: - type: linux_bond name: bond1 members: - type: interface name: nic2 - type: interface name: nic3 bonding_options: "mode=802.3ad lacp_rate=[fast|slow] updelay=1000 miimon=100" ...- 示例 - Linux 绑定设置为带有一个 VLAN 的
active-backup模式 .... edpm_network_config_template: | --- {% set mtu_list = [ctlplane_mtu] %} {% for network in nodeset_networks %} {{ mtu_list.append(lookup(vars, networks_lower[network] ~ _mtu)) }} {%- endfor %} {% set min_viable_mtu = mtu_list | max %} network_config: - type: linux_bond name: bond_api bonding_options: "mode=active-backup" use_dhcp: false dns_servers: get_param: DnsServers members: - type: interface name: nic3 primary: true - type: interface name: nic4 - type: vlan vlan_id: {{ lookup(vars, networks_lower[network] ~ _vlan_id) }} device: bond_api addresses: - ip_netmask: get_param: InternalApiIpSubnet- 示例 - OVS 网桥上的 Linux 绑定
在本例中,绑定被设置为带有 LACP 模式的
802.3ad,以及一个 VLAN:... edpm_network_config_template: | --- {% set mtu_list = [ctlplane_mtu] %} {% for network in nodeset_networks %} {{ mtu_list.append(lookup(vars, networks_lower[network] ~ _mtu)) }} {%- endfor %} {% set min_viable_mtu = mtu_list | max %} network_config: - type: ovs_bridge name: br-tenant use_dhcp: false mtu: 9000 members: - type: linux_bond name: bond_tenant bonding_options: "mode=802.3ad updelay=1000 miimon=100" use_dhcp: false dns_servers: get_param: DnsServers members: - type: interface name: p1p1 primary: true - type: interface name: p1p2 - type: vlan vlan_id: {get_param: TenantNetworkVlanID} addresses: - ip_netmask: {get_param: TenantIpSubnet} ...