sentos中bonding(网卡绑定技术)1

  1. balance-rr (mode=0)       默认, 有高可用 (容错) 和负载均衡的功能,  需要交换机的配置,每块网卡轮询发包 (流量分发比较均衡).
  2. active-backup (mode=1)  只有高可用 (容错) 功能, 不需要交换机配置, 这种模式只有一块网卡工作, 对外只有一个mac地址。缺点是端口利用率比较低
  3. balance-xor (mode=2)     不常用
  4. broadcast (mode=3)        不常用
  5. 802.3ad (mode=4)          IEEE 802.3ad 动态链路聚合,需要交换机配置
  6. balance-tlb (mode=5)      不常用
  7. balance-alb (mode=6)     有高可用 ( 容错 )和负载均衡的功能,不需要交换机配置  (流量分发到每个接口不是特别均衡)。

一、GRUB添加kernel参数

1.# vim /etc/sysconfig/grub
GRUB_CMDLINE_LINUX="......      net.ifnames=0"
2.重新装载配置文件
# grub2-mkconfig -o /boot/grub2/grub.cfg
3. reboot
# reboot

二、具体步骤(提前准备两个网卡)

1. 接口配置文件

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=192.168.40.128
PREFIX=24
USERCTL=no
GATEWAY=192.168.40.2
DNS1=202.96.0.133               
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
USERCTL=no
NM_CONTROLLED=no
MASTER=bond0
SLAVE=yes

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1(同eth0)

2. bonding参数
# vim  /etc/modprobe.d/bond0.conf
alias  bond0   bonding
options bonding mode=0 miimon=100

3. 重启网络服务
# systemctl restart network
# ip a

4.查看

[root@localhost ~]# ethtool   bond0
Settings for bond0:
        Supported ports: [ ]
        Supported link modes:   Not reported
        Supported pause frame use: No
        Supports auto-negotiation: No
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: 2000Mb/s
        Duplex: Full
        Port: Other
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        Link detected: yes

 deb系做bond

bonding技术是linux系统内核层面实现的,它是一个内核模块(驱动),注意检查驱动lsmod。使用它需要系统有这个模块, 我们可以modinfo命令查看下这个模块的信息, 一般来说都支持。

# modprobe bonding   (加载bond模块)
# lsmod | grep bonding
bonding     163840      0

在网络流量较大的场景下推荐使用bond 0;在可靠性要求较高的场景下推荐使用bond 1。

auto lo
iface lo inet loopback
 
auto bond0
iface bond0 inet static
  bond-miimon 100 (表示监控频率,多久时间要检查网络一次,单位是ms(毫秒),100是初始默认值)
  bond-mode 0
  bond-slaves eth0 eth2
  address 120.1.20.1
  netmask 255.255.255.128
  gateway 120.1.20.126
 
auto eth0
iface eth0 inet manual
  bond-master bond0
 
auto eth2
iface eth2 inet manual
  bond-master bond0
 
auto bond1
iface bond1 inet static
    bond-miimon 100
    bond-mode 0
    bond-slaves eth4 eth5
    address 120.1.20.135
    netmask 255.255.255.128
 
auto eth4
iface eth4 inet manual
    bond-master bond1
auto eth5
iface eth5 inet manual (manual表示手动配置地址)
    bond-master bond1



原文地址:https://www.cnblogs.com/zjz20/p/11285034.html