标签: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.1 DNS1=202.106.0.20 DEVICE=bond0 BOOTPROTO=none NETMASK=255.255.255.0 TYPE=Ethernet IPADDR=192.168.10.100 ONBOOT=yes USERCTL=no
也可以使用 setup 命令进入网卡配置模式,添加一块行的网卡: <New Device> --> Ethernet--> Name :bond0 --> Device:bond0 ……保存后-->进入bond0的配置文件,将ONBOOT参数改为yes。
2.修改网卡em1和em2 配置
DEVICE=em1 ## 网卡em1:DEVICE 参数为em1 网卡em2:DEVICE 参数为em2 ONBOOT=no TYPE=Ethernet MASTER=bond0 BOOTPROTO=none USERCTL=no SLAVE=yes IPV6INIT=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 信息:
[root@localhost 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)
++++++++++++++++++++++++++++++++++++++++++
[root@localhost 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
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[root@localhost 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
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[root@localhost 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
+++++++++++++++++++++++++++++++++++++++++++++++
[root@localhost bonding]# ethtool bond0
Settings for bond0:
Link detected: yes
标签:des style blog http color os 使用 io strong
原文地址:http://www.cnblogs.com/weijie0717/p/3944653.html