• 如何进行对多网口的链路聚合配置


    Network eth

    在Linux 服务器下进行多网口的 负载均衡

    1. 插件安装
    apt-get install ifenslave
    
    1. 配置interfaces
    auto lo bond0 eth0 eth1
    iface bond0 inet static
    address 192.168.4.134
    netmask 255.255.255.0
    network 192.168.4.0
    broadcast 192.168.4.255
    gateway 192.168.4.1
    up /sbin/ifenslave bond0 eth0
    up /sbin/ifenslave bond0 eth1
    # The primary network interface
    iface lo inet loopback
    iface eth0 inet static
    address 192.168.4.135
    netmask 255.255.255.0
    iface eth1 inet static
    address 192.168.4.136
    netmask 255.255.255.0
    

    3、把bond模块加入到/etc/modules

    alias bond0 bonding
    options bond0 mode=balance-alb miimon=100 max_bonds=2
    

    说明:miimon是用来进行链路监测的。 比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;mode的值表示工作模式,他共有0,1,2,3四种模式,常用的为0,1两种。
    mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
    mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.
    bonding只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外的链路down掉了,而交换机本身并没有故障,那么bonding会认为链路没有问题而继续使用 .
    4、重启网卡
    5、加入开机启动

    modprobe bonding max_bonds=2
    

    创建一个bond设备,三个简单的步骤即可搞定:
    (1)首先要保证相应的驱动程序已经加载:

    localhost@root ~# modprobe bonding
    

    modprobe <3c59x| eepro100|pcnet32|tulip|...>
    

    (2)其次给等梆定bond设备分配IP地址

    localhost@root ~# ifconfig bond0 <IP地址> netmask <子网掩码> broadcast <广播地址 >
    

    例如

     ifconfig bond0 192.168.1.242 netmask 255.255.255.0 broadcast 
    172.31.3.254
    

    (3)最后将所有要梆定的物理网卡接口添加到bond设备中去

    localhost@root ~# ifenslave bond0 [{-f|--force} bond0 eth0 [ eth1 [eth2]...]
    

    例如

    ifenslave bond0 eth0 eth1
    

    梆定了eth0 eth1两个网卡设备。 --force 表示强制进行梆

    创建好bond设备后,就可以像一般的网卡设备一样使用了
    如启动bond0: # ifconfig bond0 up
    停用bond0: # ifconfig bond0 down
    在不停用bond0的情况下添加接口: # ifenslave {-d| --detach} bond0 eth0 [eth1 [eth2]...]
    --detach表示"附加"的意思
    改变活动的从设备: # ifenslave {-c|--change-active} bond0 eth0
    --change-acitve 表示"改变活动的从设备"的意思
    显示主接口(指bond0)信息: # ifenslave bond0
    显示所以接口信息: # ifenslave {-a|--all-interfaces}
    --all-interfaces 表示"所有接口"

  • 相关阅读:
    Django 同步数据库的时候app中的models的表没有成功创建
    mysql 个人博客应用的建表和相关查询
    lambda(),map(),filter()
    用小白鼠找毒药
    python 汉诺塔问题
    灰色预测
    python可视化图标
    exel数据可视化
    543. 二叉树的直径
    236. 二叉树的最近公共祖先
  • 原文地址:https://www.cnblogs.com/Qingluan/p/5137134.html
Copyright © 2020-2023  润新知