[root@oracle ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:5D:72:D4
inet addr:10.2.34.200 Bcast:10.2.34.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe5d:72d4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:724 errors:0 dropped:0 overruns:0 frame:0
TX packets:240 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:59917 (58.5 KiB) TX bytes:30862 (30.1 KiB)
Base address:0xd010 Memory:f0000000-f0020000
eth1 Link encap:Ethernet HWaddr 08:00:27:87:EE:D7
inet addr:10.2.34.115 Bcast:10.2.34.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe87:eed7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1072 errors:0 dropped:0 overruns:0 frame:0
TX packets:166 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:88972 (86.8 KiB) TX bytes:16395 (16.0 KiB)
Base address:0xd240 Memory:f0820000-f0840000
[root@oracle ~]# cd /etc/sysconfig/network-scripts/
[root@oracle network-scripts]# cp ifcfg-eth0
ifcfg-eth0 ifcfg-eth0.bak
[root@oracle network-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@oracle network-scripts]# vim ifcfg-bond0
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=10.2.34.200
GATEWAY=10.2.34.254
TYPE=Ethernet
[root@oracle network-scripts]# vim ifcfg-eth0
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:27:5d:72:d4
MASTER=bond0
SLAVE=yes
[root@oracle network-scripts]# vim ifcfg-eth1
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth1
ONBOOT=yes
HWADDR=08:00:27:87:ee:d7
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
[root@oracle network-scripts]# vim /etc/modprobe.conf
在該文件的最下面添加如下2行
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)提供冗餘功能,工作方式是主備的工作方式,也就是說默認情況下只有一塊網卡工作,另一塊做備份.
[root@oracle network-scripts]# vim /etc/rc.local
添加如下2行
ifenslave bond0 eth0 eth1
route add -net 10.2.34.0 netmask 255.255.255.0 bond0
重啓服務器