redhat 5.6下网卡冗余实验
目前在各个发行版本的 Linux 中,使用最普遍的内核版本应该就是 2.4.x的版本了,而 Linux Channel Bonding, 在Linux 2.4 的内核中,
就提供了 bonding 的驱动, 可以支持把多个网络适配器集合在一起, 当作一个网络适配器来使用。在 Linux 下,网卡的高可用性是通过 MII
或者 ETHTOOL 的状态监测来实现的,所以,需要检查系统中的网络适配器是否支持 MII或者 ETHTOOL 的连状态监测。可以用命令 "ethtool
eth0" 来检查,如果显示的 "Link detected:"信息与实现的连接状态一致,就没有问题。如果系统中的网络适配器不支持 MII 或者 ETHTOOL
状态监测,当连接失效时,系统就不能检测到,同时,在 bonding 驱动加载时,会记录一条不支持 MII 和 ETHTOOL 的警告信息。
实验准备:
一台redhat5.6系统虚拟机,配置两个网卡 一个静态ip:172.16.100.2/24
当mode=1时为主备模式,mode=0时为负载均衡模式。
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
Type=Ethernet
SLAVE=yes
MASTER=bond0
IPV6INIT=no
USERCTL=no
# cp ifcfg-eth0 ifcfg-eth1
# vi ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
Type=Ethernet
SLAVE=yes
MASTER=bond0
IPV6INIT=no
USERCTL=no
# cp ifcfg-eth0 ifcfg-bond0
# vi ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
BROADCAST=172.16.100.255
IPADDR=172.16.100.2
NETMASK=255.255.255.0
NETWORK=172.16.100.0
TYPE=Ethernet
ONBOOT=yes
IPV6INIT=no
USERCTL=no
# vi /etc/modprobe.d/bond.conf
alias bond0 bonding
options bond0 miimon=50 mode=1 #50毫秒监控一次,使用冗余1模式,即一备一
# cat /boot/config-2.6.18-238.el5 |grep BONDING
CONFIG_BONDING=m
# modprobe bonding
# lsmod |grep bonding
bonding 100449 0
ipv6 270049 2 bonding,cnic
将bonding加入开机启动
#vi /etc/rc.d/rc.local
加一行 modprobe bonding
重启机器。
# cat /proc/net/bonding/bond0 此时工作网卡为eth0
客户端做ping测试,同时断开eth0,可以看到客户端丢了一个包,同时查看日志,如下
在# cat /proc/net/bonding/bond0,可以看到当前工作网卡已经切换为eth1了
修改bonding配置文件 /etc/modprobe.d/bond.conf 将mode 改为0,负载均衡模式
重启机器
启动后,# cat /proc/net/bonding/bond0, 已经变为了round-robin (负载均衡模式)
此时,断开网卡eth0
# cat /proc/net/bonding/bond0 ,如下
页:
[1]