RHEL6.2下多網卡的bonding 成一塊網卡
(1)為什么要做多網卡bonding成一塊網卡
A、網卡及網絡鏈路冗餘
當一個網卡故障,或是一個網卡所對應的網絡鏈路有故障時,
另一網卡及對應的網絡鏈路可正常工作,對應應用場景為:
ORACLE RAC多節點主機的心跳網絡,主機的網卡可進行bonding,
以提供網絡冗餘。
B、增加主機的網絡帶寬
多塊網卡可同時工作,分擔主機的網絡流量。對于主機的網絡IO很大時
可分擔主機的網絡流量。
(2)綁定網卡的工作模式
mode=0:表示負載均衡方式,兩塊網卡都工作
mode=1:自動備援模式,提供冗餘,其中一條線若斷線,其他線路將會自動備援。
一個物理網卡處於主狀態 ,一個物理網卡處於從狀態,所有流量都在主
鏈路上處理,從鏈路不會有任何流量。當主網卡down掉時,從網卡接手主狀態。
mode=2:(balance-xor) XOR policy(平衡策略),基於指定的傳輸HASH策略傳輸資料包
該模式將限定流量,以保證到達特定對端的流量總是從同一個介面上發出。
既然目的地是通過MAC位址來決定的,因此該模式在"本地"網路配置下可以工作得很好。
如果所有流量是通過單個路由器(比如 "閘道"型網路配置,只有一個閘道時,源和目標
mac都固定了,那麼這個演算法算出的線路就一直是同一條,那麼這種模式就沒有多少意義了。),
那該模式就不是最好的選擇。和balance-rr一樣,交換機埠需要能配置為"port channel"。
這模式是通過源和目標mac做hash因數來做xor演算法來選路的。
mode=3:廣播容錯,一個報文會複製兩份往bond下的兩個介面分別發送出去
(3)在RHEL6.2上設定多網卡的bonding
--OS版本
[root@hzlh-hr20121226 ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.2 (Santiago)
Release: 6.2
Codename: Santiago
--內核版本
[root@hzlh-hr20121226 ~]# uname -a
Linux hzlh-hr20121226 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
--bonding支持
[root@hzlh-hr20121226 ~]# modinfo bonding
filename: /lib/modules/2.6.32-220.el6.x86_64/kernel/drivers/net/bonding/bonding.ko
author: Thomas Davis, tadavis@lbl.gov and many others
description: Ethernet Channel Bonding Driver, v3.6.0
version: 3.6.0
license: GPL
srcversion: B956376CB253D2B7312733C
depends: ipv6
vermagic: 2.6.32-220.el6.x86_64 SMP mod_unload modversions
parm: .......
--網卡配置文件目錄
[root@hzlh-hr20121226 ~]# cd /etc/sysconfig/network-scripts/
--此處有4個物理網卡文件
[root@hzlh-hr20121226 network-scripts]# ls ifcfg-eth* -al
-rw-r--r--. 1 root root 73 Dec 26 11:12 ifcfg-eth0
-rw-r--r--. 1 root root 276 Dec 27 16:19 ifcfg-eth1
-rw-r--r--. 1 root root 73 Dec 26 11:12 ifcfg-eth2
-rw-r--r--. 1 root root 73 Dec 26 11:12 ifcfg-eth3
--我計劃將eth0和eth1兩個物理網卡綁定成一個網卡(設定為模式1,以例于oracle rac心跳網絡冗餘)
--修改前各文件的配置
[root@hzlh-hr20121226 network-scripts]# vi ifcfg-eth0
--網卡eth0目前未啟用,以下為文件內容
DEVICE="eth0"
NM_CONTROLLED="yes"
NBOOT="no"
HWADDR=AC:16:2D:6E:D0:34
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.77.77.79
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
[root@hzlh-hr20121226 network-scripts]# vi ifcfg-eth1
--網卡eth1目前啟用,以下為文件內容
DEVICE="eth1"
NM_CONTROLLED="yes"
NBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.197.10.99
PREFIX=24
GATEWAY=10.197.10.1
DNS1=10.197.10.60
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="System eth1"
UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04
HWADDR=AC:16:2D:6E:D0:35
--建立bond網卡文件
[root@hzlh-hr20121226 network-scripts]# vi ifcfg-bond0
DEVICE="bond0"
BOOTPROTO=static
IPADDR=10.197.10.99
NETMASK=255.255.255.0
NM_CONTROLLED="no"
MASTER="yes"
NBOOT=yes
TYPE=Ethernet
USERCTL=no
GATEWAY=10.197.10.1
NETWORK=10.197.10.0
DNS1=10.197.10.60
BONDING_OPTS="mode=1 miimon=100 primary=eth1" ## 網卡工作模式為主備模式,主網卡為eth1
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System bond0"
--修改網卡eth0的設定檔
[root@hzlh-hr20121226 network-scripts]# vi ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
BOOTPROTO=none
MASTER="bond0" ##綁定網卡名
SLAVE=yes
NBOOT="yes"
HWADDR=AC:16:2D:6E:D0:34
TYPE=Ethernet
DEFROUTE=yes
--修改網卡eth1的設定檔
[root@hzlh-hr20121226 network-scripts]# vi ifcfg-eth1
DEVICE="eth1"
NM_CONTROLLED="no"
BOOTPROTO=none
MASTER="bond0" ##綁定網卡名
SLAVE=yes
NBOOT="yes"
HWADDR=AC:16:2D:6E:D0:34
TYPE=Ethernet
DEFROUTE=yes
--查看各文件
[root@hzlh-hr20121226 network-scripts]# ls ifcfg-* -al
-rw-r--r--. 1 root root 324 Nov 24 11:50 ifcfg-bond0
-rw-r--r--. 1 root root 138 Nov 24 09:38 ifcfg-eth0
-rw-r--r--. 1 root root 138 Nov 24 09:39 ifcfg-eth1
-rw-r--r--. 1 root root 127 Nov 24 09:18 ifcfg-eth2
-rw-r--r--. 1 root root 127 Nov 24 09:19 ifcfg-eth3
-rw-r--r--. 1 root root 254 Oct 7 2011 ifcfg-lo
--重啟網絡服務,查看網絡狀況
[root@hzlh-hr20121226 network-scripts]# service network restart
[root@hzlh-hr20121226 network-scripts]# ifconfig
bond0 Link encap:Ethernet HWaddr AC:16:2D:6E:D0:34
inet addr:10.197.10.99 Bcast:10.197.10.255 Mask:255.255.255.0
inet6 addr: fe80::ae16:2dff:fe6e:d034/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:558878876 errors:0 dropped:0 overruns:0 frame.:0
TX packets:493694084 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:490180406187 (456.5 GiB) TX bytes:273450567957 (254.6 GiB)
eth0 Link encap:Ethernet HWaddr AC:16:2D:6E:D0:34
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:26117222 errors:0 dropped:0 overruns:0 frame.:0
TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8209759860 (7.6 GiB) TX bytes:18552 (18.1 KiB)
Interrupt:32
eth1 Link encap:Ethernet HWaddr AC:16:2D:6E:D0:34
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:532761654 errors:0 dropped:0 overruns:0 frame.:0
TX packets:493693944 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:481970646327 (448.8 GiB) TX bytes:273450549405 (254.6 GiB)
......
--到此配置完成,可自行拔除對應網卡的網線測試網絡鏈路的工作狀況。
~
~
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27348/viewspace-752559/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27348/viewspace-752559/