zoukankan      html  css  js  c++  java
  • Linux服务器网卡绑定配置(loongnix)

    1.首先关闭NetworkManager服务

    service NetworkManager stop

    2、查看网卡名称,确定要绑定的网卡,本次配置选择双网卡绑定

    ifconfig  #使用ifconfig命令可以看到网卡的列表

    实现物理网口enp5s0f0,enp5s0f1网卡绑定,绑定后的虚拟逻辑网口bond0

    3、modinfo bonding 检查自己的操作系统是否支持bonding

    [root@localhost ~]# modinfo bonding
    filename:       /lib/modules/3.10.0-693.lns7.8.mips64el/kernel/drivers/net/bonding/bonding.ko
    author:         Thomas Davis, tadavis@lbl.gov and many others
    description:    Ethernet Channel Bonding Driver, v3.7.1
    version:        3.7.1
    license:        GPL
    alias:          rtnl-link-bond
    rhelversion:    7.4
    srcversion:     694CF99DDA3170BD385D0E1
    depends:        
    intree:         Y
    vermagic:       3.10.0-693.lns7.8.mips64el SMP preempt mod_unload modversions LOONGSON3 64BIT 
    parm:           max_bonds:Max number of bonded devices (int)
    ...  ...  ...  ...
    ...  ...  ...  ...

    如果没有消息返回,说明内核不支持bonding

    4、创建网卡绑定配置文件

    cd /etc/sysconfig/network-scripts/

    备份原来的配置文件

    cp ifcfg-enp5s0f0 bak/
    cp ifcfg-enp5s0f1 bak/

    新建绑定文件

    vi ifcfg-bond0
    
    DEVICE=bond0
    TYPE=Ethernet
    ONBOOT=yes
    BOOTPROTO=none
    IPADDR=10.150.1.200
    NETMASK=255.255.255.0
    GATEWAY=10.150.1.1
    DNS1=202.99.192.68
    DNS2=8.8.8.8
    USERCTL=no

    5、修改原网卡enp5s0f0和enp5s0f1配置文件

    ifcfg-enp5s0f0:
    
    DEVICE=enp5s0f0
    ONBOOT=yes
    BOOTPROTO=none
    MASTER=bond0
    SLAVE=yes
    USERCTL=no
    ifcfg-enp5s0f1:
    
    DEVICE=enp5s0f1
    ONBOOT=yes
    BOOTPROTO=none
    MASTER=bond0
    SLAVE=yes
    USERCTL=no

    6、修改modprobe相关设定文件,并加载bonding模块

    vi /etc/modprobe.d/bonding.conf
    alias bond0 bonding
    options bonding mode=6 miimon=200

    执行命令加载模块

    modprobe bonding

    miimon=100为每100毫秒(0.1秒)检查网络一次,可以根据自己需求修改

    mode为网卡工作模式,共七种,通常设置0、1、6这几种

    7、重启网卡

    [root@localhost network-scripts]# lsmod | grep bonding
    bonding               134260  0 
    [root@localhost network-scripts]# service network restart

    8、查看绑定状态

    [root@localhost network-scripts]# cat /proc/net/bonding/bond0 
    Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
    
    Bonding Mode: fault-tolerance (active-backup)
    Primary Slave: None
    Currently Active Slave: enp5s0f0
    MII Status: up
    MII Polling Interval (ms): 100
    Up Delay (ms): 0
    Down Delay (ms): 0
    
    Slave Interface: enp5s0f0
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 00:23:9e:05:72:7f
    Slave queue ID: 0
    
    Slave Interface: enp5s0f1
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 00:23:9e:05:72:80
    Slave queue ID: 0

    9、断网测试

    (略)

    Mode模式说明:

    Mode 功能 功能说明
    0 balance-rr 负载均衡模式需要switch配置(trunk)支持才能发挥实际
    效果,具有容错功能,其中一块网卡失效仍可持续工作
    1 active-backup 同一时间终于一块网卡工作,Active Slave其中一块网卡断
    线时自动启用另一块网卡,不需要switch支持
    2 balance-xor 具容错作用
    3 broadcast 所有网卡一起收发网络数据包,具容错功能,其中一块网卡
    断线仍可持续工作
    4 802.3ad 无实际功能,不建议使用
    5 balance-tlb 发送数据包自动负载均衡,接收数据包有Current Active
    Slave 负责,具容错功能,其中一块网卡失效仍可持续工
    作,不需要switch支持配置
    6 balance-alb 发送及接收皆自动负载均衡。具有容错功能,其中一块网卡
    断线时仍可持续工作,网卡驱动程序需要支持setting
    hardware address功能,不需要switch支持及配置
  • 相关阅读:
    jar命令|jdt的简单使用
    国际化程序实现
    泛型接口
    RunTime类
    权限控制
    日期操作类
    异常
    Visual C# 2008+SQL Server 2005 数据库与网络开发―― 3.2 C# 2008多语言的新特性
    Visual C# 2008+SQL Server 2005 数据库与网络开发―― 2.6 创建项目
    Visual C# 2008+SQL Server 2005 数据库与网络开发――3.1.3 C# 2008和.NET Framework 3.5的关系
  • 原文地址:https://www.cnblogs.com/silent2012/p/12931081.html
Copyright © 2011-2022 走看看