bond的配置方法

2025-10-27 13:35:45

1、网卡bond前期准备

1.由于服务器网卡比较多,逻辑顺序与物理顺序不一定一致。首先要确定哪几块网卡布置了网线,一般是有两块网卡对应两根网线,分别连接不同的交换机。查看所有网卡

$lspci|grep net

查看网卡2的信息,Link detected:yes表示有网线插入

$ethtool eth2

如果Link detected:no 的话,尝试用命令ifconfig eth2 up,如果用ethtool查看任然为no的话,才能说明此网卡确实没有网线插入。

2.注意如果ifcfg-bond0的配置文件如果是从其他网卡配置文件拷贝过来的,HWADDR地址一定要删除,DEVICE名字要改。

3.NetworkManager要关闭,建议临时和永久都关闭一下。

$chkconfig NetworkManager off$service NetworkManager stop

在《linux就该这么学》中查看负载均衡的配置。

2、更改要bond网卡的配置文件

eth2,eth3为bond前的网卡名称,bond0为bond后的网卡名称,我们需要对这三个配置文件做更改。

eth2:

$vi /etc/sysconfig/network-scripts/ifcfg-eth2 DEVICE=eth2 HWADDR=44:A8:42:25:7C:FE BOOTPROTO=none ONBOOT=yes SLAVE=yes MASTER=bond0 TYPE=Ethernet

eth3:

$vi /etc/sysconfig/network-scripts/ifcfg-eth3 DEVICE=eth3 HWADDR=44:A8:42:25:7D:01 BOOTPROTO=none ONBOOT=yes SLAVE=yes MASTER=bond0 TYPE=Ethernet

bond0:

$vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 BOOTPROTO=static ONBOOT=yes IPADDR=100.100.100.100 NETMASK=255.255.255.0 GATEWAY=100.100.100.1 TYPE=Ethernet

3、配置模式为bond6$vi /etc/modprobe.d/dist.conf

在最后添加下面2行

alias bond0 bonding options bond0 miimon=100 mode=6

也可以用下面的命令添加

$sed -i '$a alias bond0 bonding' /etc/modprobe.d/dist.conf$sed -i '$a options bond0 miimon=100 mode=6' /etc/modprobe.d/dist.conf

4、重启网络服务$service network restart

5、用nload查看流量$vim /root/.bash_profileexport PATH alias nload='nload -m -s 5 -u m -t 2000 bond0 eth2 eth3'$source /root/.bash_profile$nload

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢