I. Configure the environment
Centos 6.2 system. Link aggregation is performed on one and two NICs. The vswitch has six or seven Network Ports.
Ii. server operation steps
1. Create a channel Bonding Interface
# Vi/etc/sysconfig/network-scripts/ifcfg-bond0Add the following lines:Gateway = 192.168.10.1dns1 = 202.106.0.20device = bond0bootproto = nonenetmask = 255.255.255.0type = ethernetipaddr = 192.168.10.100onboot = yesuserctl = No
You can also run the setup command to enter the NIC configuration mode and add a line NIC: <New Device> --> Ethernet --> name: bond0 --> device: bond0 ...... Save the file --> enter the bond0 configuration file and change the onboot parameter to yes.
2. Modify the EM1 and EM2 configurations of the NIC.
Device = Em1 # network card Em1: device parameter is Em1 network card EM2: device parameter is em2onboot = notype = ethernetmaster = bond0bootproto = noneuserctl = noslave = yesipv6init = No
3. Edit the bond0.conf configuration file and configure the bond mode.
Create the Bond. config configuration file:
Add the following lines to VI/etc/modprobe. d/bond0.conf: alias bond0 Bonding
Modify bond mode: (Mode 0: Server Load balancer)
Echo 0>/sys/class/NET/bond0/Bonding/Mode
Restart the NIC service: Service Network restart (restart the NIC service after the channel is configured on the switch, so that you can continuously connect to the server)
Note:
The value of mode indicates the working mode. There are 7 modes: 0, 1, 2, 3, 4, 5, and 6, which are commonly used: 0, 1.
Mode = 0 indicates that the load balancing (round-robin) method is load balancing, and both NICs work.
Mode = 1 indicates that fault-tolerance (Active-Backup) provides redundancy, working in the active/standby mode. That is to say, by default, only one network card works and the other is used for backup.
Mode = 2 indicates balance-X, which provides load balancing and redundancy functions.
Mode = 3 indicates broadcast, which provides fault tolerance.
Mode = 4 indicates 802.3ad, which provides rapid ethtool and uses the 802.3ad mode.
Mode = 5 indicates balance-TLB. It automatically adapts to Server Load balancer and automatically switches to the fault. Based on this, ethtool supports drivers.
Mode = 6 indicates that the ARP broadcast information is optimized based on the 5 mode.
For details about the bonding mode and the required conditions, see:
Http://blog.chinaunix.net/uid-49097-id-78251.html
Iii. configurations under a vswitch:
(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
Iv. Host show information:
[[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 FIG: 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 FIG: 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 in 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 100 mb/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 100 mb/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 100 mb/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 100 mb/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: 10 BaseT/half 10 BaseT/full
100 Baset/half 100 Baset/full
1000 Baset/full
Supports auto-negotiation: Yes
Advertised link modes: 10 BaseT/half 10 BaseT/full
100 Baset/half 100 Baset/full
1000 Baset/full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000 MB/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: 10 BaseT/half 10 BaseT/full
100 Baset/half 100 Baset/full
1000 Baset/full
Supports auto-negotiation: Yes
Advertised link modes: 10 BaseT/half 10 BaseT/full
100 Baset/half 100 Baset/full
1000 Baset/full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000 MB/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 Nic aggregation and Cisco switch link Aggregation