標籤:des style blog http color os 使用 io strong
一、配置環境
centos 6.2系統。網卡1口和2口做鏈路彙總。 交換器網口 6口和7口。
二、伺服器操作步驟
1.建立一個channel bonding interface
#vi /etc/sysconfig/network-scripts/ifcfg-bond0添加如下幾行:GATEWAY=192.168.10.1DNS1=202.106.0.20DEVICE=bond0BOOTPROTO=noneNETMASK=255.255.255.0TYPE=EthernetIPADDR=192.168.10.100ONBOOT=yesUSERCTL=no
也可以使用 setup 命令進入網卡配置模式,添加一塊行的網卡: <New Device> --> Ethernet--> Name :bond0 --> Device:bond0 ……儲存後-->進入bond0的設定檔,將ONBOOT參數改為yes。
2.修改網卡em1和em2 配置
DEVICE=em1 ## 網卡em1:DEVICE 參數為em1 網卡em2:DEVICE 參數為em2ONBOOT=noTYPE=EthernetMASTER=bond0BOOTPROTO=noneUSERCTL=noSLAVE=yesIPV6INIT=no
3.編輯bond0.conf設定檔,及配置bond模式
建立bond.config設定檔:
vi /etc/modprobe.d/bond0.conf添加如下行:alias bond0 bonding
修改bond模式:(mode 0:為負載平衡)
echo 0 > /sys/class/net/bond0/bonding/mode
重啟網卡服務:service network restart (在交換器也做好channel後再重啟網卡服務,這樣可以和伺服器不中斷連線)
註:
mode的值表示工作模式,他共有0,1,2,3,4,5,6這7種模式,常用的為0,1兩種。
mode=0表示load balancing (round-robin)為負載平衡方式,兩塊網卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗餘功能,工作方式是主備的工作方式,也就是說預設情況下只有一塊網卡工作,另一塊做備份.
mode=2表示balance-x,提供負載平衡和冗餘功能。
mode=3表示broadcast,這個模式提供容錯性。
mode=4表示802.3ad,提供了ethtool的迅速,以及使用了802.3ad模式
mode=5表示balance-tlb,自動適應負載平衡,自動切換故障。在此基礎上Ethtool支援驅動。
mode=6表示在5模式的基礎上最佳化了arp的廣播資訊。
bonding模式介紹和所需條件詳見:
http://blog.chinaunix.net/uid-49097-id-78251.html
三、交換器下的配置:
(config)#interface range gigabitEthernet 0/6 -7(config-if-range)#switchport access vlan 10 (config-if-range)#channel-protocol lacp(config-if-range)#channel-group 3 mode active(config)#interface port-channel 3(config-if)#switchport access vlan 10
四、主機show 資訊:
[[email protected] bonding]# ifconfig
bond0 Link encap:Ethernet HWaddr 14:FE:B5:C8:1A:B7
inet addr:192.168.10.100 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::16fe:b5ff:fec8:1ab7/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:60730879 errors:0 dropped:0 overruns:0 frame:0
TX packets:10640 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:11017881974 (10.2 GiB) TX bytes:1221132 (1.1 MiB)
em1 Link encap:Ethernet HWaddr 14:FE:B5:C8:1A:B7
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:30367565 errors:0 dropped:0 overruns:0 frame:0
TX packets:5315 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5509317809 (5.1 GiB) TX bytes:607884 (593.6 KiB)
Interrupt:24 Memory:e6000000-e6012800
em2 Link encap:Ethernet HWaddr 14:FE:B5:C8:1A:B7
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:30363314 errors:0 dropped:0 overruns:0 frame:0
TX packets:5325 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5508564165 (5.1 GiB) TX bytes:613248 (598.8 KiB)
Interrupt:25 Memory:e8000000-e8012800
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:2163 errors:0 dropped:0 overruns:0 frame:0
TX packets:2163 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3604424 (3.4 MiB) TX bytes:3604424 (3.4 MiB)
++++++++++++++++++++++++++++++++++++++++++
[[email protected] bonding]# dmesg | grep bond0
Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-bond0 instead
bonding: bond0: setting mode to balance-rr (0).
ADDRCONF(NETDEV_UP): bond0: link is not ready
bonding: unable to remove non-existent slave em1 for bond bond0.
bonding: unable to remove non-existent slave em2 for bond bond0.
ADDRCONF(NETDEV_UP): bond0: link is not ready
bonding: bond0: Adding slave em1.
bonding: bond0: Warning: failed to get speed and duplex from em1, assumed to be 100Mb/sec and Full.
bonding: bond0: enslaving em1 as an active interface with an up link.
ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
bonding: bond0: Adding slave em2.
bonding: bond0: Warning: failed to get speed and duplex from em2, assumed to be 100Mb/sec and Full.
bonding: bond0: enslaving em2 as an active interface with an up link.
bond0: no IPv6 routers present
bonding: bond0: Removing slave em1
bonding: bond0: Warning: the permanent HWaddr of em1 - 14:fe:b5:c8:1a:b7 - is still in use by bond0. Set the HWaddr of em1 to a different address to avoid conflicts.
bonding: bond0: releasing active interface em1
bonding: bond0: Removing slave em2
bonding: bond0: releasing active interface em2
ADDRCONF(NETDEV_UP): bond0: link is not ready
bonding: unable to remove non-existent slave em1 for bond bond0.
bonding: unable to remove non-existent slave em2 for bond bond0.
ADDRCONF(NETDEV_UP): bond0: link is not ready
bonding: bond0: Adding slave em1.
bonding: bond0: Warning: failed to get speed and duplex from em1, assumed to be 100Mb/sec and Full.
bonding: bond0: enslaving em1 as an active interface with an up link.
ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
bonding: bond0: Adding slave em2.
bonding: bond0: Warning: failed to get speed and duplex from em2, assumed to be 100Mb/sec and Full.
bonding: bond0: enslaving em2 as an active interface with an up link.
bond0: no IPv6 routers present
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[[email protected] bonding]# ethtool em1
Settings for em1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: g
Wake-on: d
Link detected: yes
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[[email protected] bonding]# ethtool em2
Settings for em2:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: g
Wake-on: d
Link detected: yes
+++++++++++++++++++++++++++++++++++++++++++++++
[[email protected] bonding]# ethtool bond0
Settings for bond0:
Link detected: yes
centos 6.2 網卡彙總及Cisco交換器鏈路彙總