Ubuntu系统服务器配置bond

在所有节点上配置,使能bond提升网络带宽,本章节以ceph1节点和Ubuntu操作系统为例进行配置说明。

  1. 在各节点修改网络配置文件。

    1. 打开“/etc/netplan/50-cloud-init.yaml”文件。
      1
      vi /etc/netplan/50-cloud-init.yaml
      
    2. “i”进入编辑模式,在文件中添加以下内容。
       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
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      # This file is generated from information provided by the datasource.  Changes
      # to it will not persist across an instance reboot.  To disable cloud-init's
      # network configuration capabilities, write a file
      # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
      # network: {config: disabled}
      network:
          ethernets:
              enp125s0f0:
                  addresses:
                  - 192.168.2.166/24    # 管理IP地址
                  nameservers:
                      addresses: []
                      search: []
                  routes:
                  -   to: default
                      via: 192.168.2.0  # 网关
      #-----------以下为bond新增内容----------------
              enp3s0:
                  dhcp4: false
              enp4s0:
                  dhcp4: false
              enp5s0:
                  dhcp4: false
              enp6s0:
                  dhcp4: false
      
          bonds:
              bond0:      # bond设备名称
                addresses: [192.168.3.166/24]    # bond后的ip地址
                interfaces:
                - enp3s0     # 组bond的设备1,设备要与交换机组bond/trunk的端口匹配
                - enp4s0     # 组bond的设备2,设备要与交换机组bond/trunk的端口匹配
                parameters:
                  mode: 802.3ad
              bond1:
                addresses: [192.168.4.166/24]
                interfaces:
                - enp5s0
                - enp6s0
                parameters:
                  mode: 802.3ad
      
          version: 2
      
      • 将每个节点的“addresses”修改为实际使用的IP地址。
      • bonds - bond0 - parameters - mode:负载均衡需要手动配置分发策略echo layer3+4 > /sys/class/net/bond0/bonding/xmit_hash_policy。
    3. “Esc”键退出编辑模式,输入:wq!,按“Enter”键保存并退出文件。

  2. 应用配置。

    1
    netplan apply
    

    若WARNING提示没有open vswitch,执行以下命令安装open vswitch即可。

    apt install openvswitch-switch

  3. 查看bond设备网络信息。

    1
    2
    apt install net-tools
    ifconfig  #or ip a
    

  4. 在所有节点重复1~3

更多系统调优配置可参考:Ceph对象存储 调优指南>系统调优