操作环境
Oracle Linux Server release 6.4
内核
Linux rac1 2.6.39-400.17.1.el6uek.x86_64
[root@RAC-2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
IPADDR=192.168.254.2
NETMASK=255.255.255.0
BROADCAST=192.168.254.1
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.254.1
USERCTL=no
"/etc/sysconfig/network-scripts/ifcfg-bond0" [New] 17L, 163C written
[root@RAC-2 ~]# cd /etc/sysconfig/network-scripts/
[root@RAC-2 network-scripts]# vi ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
~
"ifcfg-eth1" 11L, 77C written
[root@RAC-2 network-scripts]# vi ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
~
"ifcfg-eth2" 11L, 77C written
[root@RAC-2 network-scripts]# vi /etc/modprobe.d/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=1
~
~
"/etc/modprobe.d/modprobe.conf" [New] 4L, 54C written
说明:
miimon是用来进行链路监测的,比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;mode的值表示工作模式,他共有0,1,2,3四种模式,常用的为0,1两种。
mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.
[root@RAC-2 network-scripts]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
ifenslave bond0 eth2 eth1
~
"/etc/rc.d/rc.local" 8L, 246C written
[root@RAC-2 network-scripts]# ifconfig bond0 192.168.254.2 up
#[root@rac4 network-scripts]# ifenslave bond0 eth2 eth1
Illegal operation: The specified slave interface 'eth0' is already a slave
最后重启服务器:
[root@rac4 ~]# reboot
从下面BOND网卡已经启动了
[root@RAC-2 ~]# ifconfig
bond0 Link encap:Ethernet HWaddr 08:00:27:E7:1F:5D
inet addr:192.168.254.2 Bcast:192.168.254.1 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee7:1f5d/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:35 errors:0 dropped:15 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2498 (2.4 KiB) TX bytes:1028 (1.0 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:E7:1F:5D
inet addr:192.168.254.2 Bcast:192.168.254.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:87 errors:0 dropped:12 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6411 (6.2 KiB) TX bytes:288 (288.0 b)
eth2 Link encap:Ethernet HWaddr 08:00:27:99:BE:CC
inet addr:192.168.254.2 Bcast:192.168.254.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:73 errors:0 dropped:62 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4935 (4.8 KiB) TX bytes:740 (740.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)
下面看当前活动网卡ech1,状态是启动
[root@RAC-2 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)