分类: LINUX
2009-03-23 11:16:48
3 # vi /etc/moprobe.conf 编辑/etc/moprobe.conf 文件,加入如下一行内容,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0 加入下列两行 alias bond0 bonding options bond0 miimon=100 mode=1 说明: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 # vi /etc/rc.d/rc.local 加入两行 ifenslave bond0 eth0 eth1 route add -net 172.31.3.254 netmask 255.255.255.0 bond0 (如果有对外交换机要加) 到这时已经配置完毕重新启动机器. 重启会看见以下信息就表示配置成功了 ................ Bringing up interface bond0 OK Bringing up interface eth0 OK Bringing up interface eth1 OK ................ 下面我们讨论以下mode分别为0,1时的情况 mode=1工作在主备模式下,这时eth1作为备份网卡是no arp的 [root@rhas-13 network-scripts]# ifconfig 验证网卡的配置信息 bond0 Link encap:Ethernet HWaddr 00:0E: inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:18495 errors:0 dropped:0 overruns:0 frame:0 TX packets:480 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1587253 (1.5 Mb) TX bytes:89642 (87.5 Kb) eth0 Link encap:Ethernet HWaddr 00:0E: inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:9572 errors:0 dropped:0 overruns:0 frame:0 TX packets:480 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:833514 (813.9 Kb) TX bytes:89642 (87.5 Kb) Interrupt:11 eth1 Link encap:Ethernet HWaddr 00:0E: inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0 UP BROADCAST RUNNING NOARP SLAVE MULTICAST MTU:1500 Metric:1 RX packets:8923 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:753739 (736.0 Kb) TX bytes:0 (0.0 b) Interrupt:15 那也就是说在主备模式下,当一个网络接口失效时(例如主交换机掉电等),不回出现网络中断,系统会按照cat /etc/rc.d/rc.local里指定网卡的顺序工作,机器仍能对外服务,起到了失效保护的功能. 通过查看bond0的工作状态查询能详细的掌握bonding的工作状态 [root@cl303 ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 10 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Link Failure Count: 0 Permanent HW addr: 00: Slave Interface: eth1 MII Status: up Link Failure Count: 0 Permanent HW addr: 00: 在mode=0 负载均衡工作模式,他能提供两倍的带宽,下我们来看一下网卡的配置信息 [root@rhas-13 root]# ifconfig bond0 Link encap:Ethernet HWaddr 00:0E: inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:2817 errors:0 dropped:0 overruns:0 frame:0 TX packets:95 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:226957 (221.6 Kb) TX bytes:15266 (14.9 Kb) eth0 Link encap:Ethernet HWaddr 00:0E: inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:1406 errors:0 dropped:0 overruns:0 frame:0 TX packets:48 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:113967 (111.2 Kb) TX bytes:7268 (7.0 Kb) Interrupt:11 eth1 Link encap:Ethernet HWaddr 00:0E: inet addr:172.31.0.13 Bcast:172.31.3.255 Mask:255.255.252.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:1411 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:112990 (110.3 Kb) TX bytes:7998 (7.8 Kb) Interrupt:15 在这种情况下出现一块网卡失效,仅仅会是服务器出口带宽下降,也不会影响网络使用. [root@cl303 ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v Bonding Mode: load balancing (round-robin) MII Status: up MII Polling Interval (ms): 1 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Link Failure Count: 0 Permanent HW addr: 00: Slave Interface: eth1 MII Status: up Link Failure Count: 0 Permanent HW addr: 00: |