美文网首页
Centos7 多网卡绑定实现负载均衡

Centos7 多网卡绑定实现负载均衡

作者: 晨曦_zdq | 来源:发表于2020-08-13 14:41 被阅读0次
    1. 常见绑定模式
    常用的有三种
    mode=0:平衡负载模式,有自动备援,但需要交换机支持及设定,       两个交换机端口需要做聚合,该模式下bond所绑定的网卡的IP都被修改成相同的mac地址,交换机做了聚合后,聚合下的几个端口也被捆绑成一个mac地址。
    mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。
    mode=6:平衡负载模式,有自动备援,不用交换机支持,绑定的是不同的MAC地址。
    
    1. 以双网卡配置示例
    #查看bonding模块是否加载
    lsmod | grep bonding 
     bonding 136705 0 
    #如果没有加载,手动先加载
    modprobe bonding
    #在/etc/sysconfig/network-scripts目录下配置ens33,ens37,bond0三个网卡接口,bond0是抽象网卡
    [root@wangguan network-scripts]# cat ifcfg-enp5s0
    TYPE=Ethernet
    BOOTPROTO=none
    DEVICE=enp5s0
    ONBOOT=yes
    USERCTL=no
    MASTER=bond0
    SLAVE=yes
    BONDING_MASTER=yes
    
    [root@wangguan network-scripts]# cat ifcfg-enp8s0
    TYPE=Ethernet
    BOOTPROTO=none
    DEVICE=enp8s0
    ONBOOT=yes
    USERCTL=no
    MASTER=bond0
    SLAVE=yes
    BONDING_MASTER=yes
    
    #实际是把原来网卡1的ip配置放入了bond0里
    [root@wangguan network-scripts]# cat ifcfg-bond0 
    TYPE=Bond
    DEVICE=bond0
    BOOTPROTO=none
    ONBOOT=yes
    ZONE=public
    IPADDR=192.168.2.205
    NETMASK=255.255.255.0
    USERCTL=no
    NM_CONTROLLED=no
    BONDING_MASTER=yes
    BONDING_OPTS="mode=6 miimon=100"
    
    重启网络systemctl restart network,如果原来network就没启动,那么使用systemctl start network
    #enp5s0和enp8s0应该是没有配置IP的
    [root@wangguan network-scripts]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
        link/ether 00:90:27:e3:02:de brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.153/24 brd 192.168.1.255 scope global enp1s0
           valid_lft forever preferred_lft forever
    3: enp5s0: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc mq master bond0 state DOWN qlen 1000
        link/ether 00:90:27:e3:02:df brd ff:ff:ff:ff:ff:ff
    4: enp7s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
        link/ether 00:90:27:e3:02:e0 brd ff:ff:ff:ff:ff:ff
        inet6 2408:8207:2530:5e30:290:27ff:fee3:2e0/64 scope global mngtmpaddr dynamic 
           valid_lft 245372sec preferred_lft 158972sec
        inet6 fe80::290:27ff:fee3:2e0/64 scope link 
           valid_lft forever preferred_lft forever
    5: enp8s0: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc mq master bond0 state DOWN qlen 1000
        link/ether 00:90:27:e3:02:e1 brd ff:ff:ff:ff:ff:ff
    6: enp11s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
        link/ether 00:90:27:e3:02:e2 brd ff:ff:ff:ff:ff:ff
        inet6 2408:8207:2530:5e30:290:27ff:fee3:2e2/64 scope global mngtmpaddr dynamic 
           valid_lft 245371sec preferred_lft 158971sec
        inet6 fe80::290:27ff:fee3:2e2/64 scope link 
           valid_lft forever preferred_lft forever
    7: enp12s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
        link/ether 00:90:27:e3:02:e3 brd ff:ff:ff:ff:ff:ff
        inet6 2408:8207:2530:5e30:290:27ff:fee3:2e3/64 scope global mngtmpaddr dynamic 
           valid_lft 245372sec preferred_lft 158972sec
        inet6 fe80::290:27ff:fee3:2e3/64 scope link 
           valid_lft forever preferred_lft forever
    8: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
        link/ether 52:54:00:9d:d6:e0 brd ff:ff:ff:ff:ff:ff
        inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
           valid_lft forever preferred_lft forever
    9: virbr0-nic: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
        link/ether 52:54:00:9d:d6:e0 brd ff:ff:ff:ff:ff:ff
    10: bond0: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
        link/ether 00:90:27:e3:02:df brd ff:ff:ff:ff:ff:ff
        inet 192.168.2.205/24 brd 192.168.2.255 scope global bond0
           valid_lft forever preferred_lft forever
        inet6 fe80::290:27ff:fee3:2df/64 scope link 
           valid_lft forever preferred_lft forever
    

    相关文章

      网友评论

          本文标题:Centos7 多网卡绑定实现负载均衡

          本文链接:https://www.haomeiwen.com/subject/tvebdktx.html