iT邦幫忙

DAY 29
4

Linux及虛擬化平台維運分享系列 第 26

[Day29 - Linux] Configure Channel Bonding on RHEL platform

  • 分享至 

  • xImage
  •  

維運RHEL平台實體主機,時常將多張網卡配置為Channel Bonding設定,其主要目的在於提升:
・Network throughput
・Load balance
・Fault tolerance
自RHEL 6開始Channel Bonding的配置方式有些許的改變,接下來本文將以實作分享
[Lab Information]
OS: Rat Hat Enterprise Linux 6.2 64 bit
Linux Kernel: 2.6.32
CPU Type: Intel Xeon CPU E5-2620 2.00GHz
CPU Core: 8
Memory: 16GB
OS root password: 12345678
Network Adapter(以下簡稱NIC)Count: 2

[Check NIC Status]
使用帳號:root執行mii-tool command及ethtool command以確認網卡狀態,如下步驟:

# command: mii-tool
[root@nagios-staging ~]# mii-tool eth0
eth0: negotiated 100baseTx-FD, link ok
[root@nagios-staging ~]# mii-tool eth1
eth1: negotiated 100baseTx-FD, link ok
#command: ethtool
[root@nagios-staging ~]# ethtool eth0
Settings for eth0:
	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: g
	Link detected: yes
[root@nagios-staging ~]# ethtool eth1
Settings for eth1:
	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: g
	Link detected: yes

[Create Channel Bonding Interface]
於目錄:/etc/sysconfig/network-scripts新增Bonding設定檔,其命名規則為:ifcfg-bondN(N為Bonding編號),本文範例為:bond0,並參閱下列步驟輸入於該設定檔:

vim /etc/sysconfig/network-scripts/ifcfg-bond0
# Add or amend the following lines in the "/etc/sysconfig/network-scripts/ifcfg-bond0" file.
DEVICE="bond0"
BOOTPROTO="none"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="no"
NETWORK="192.168.1.0"
NETMASK="255.255.255.0"
IPADDR="192.168.1.102"
BONDING_OPTS="mode=1 primary=eth0 miimon=100"

BONDING_OPTS所填入參數之資訊可參閱Bonding Interface ParametersLinux 網路結合(network bonding)技術與實務,皆有詳細說明,本文範例bonding mode:active-backup(mode=1)

[Configure Network interfaces]
分別修改NIC1(ifcfg-eth0)及NIC2(ifcfg-eth1)的設定檔內容,請參閱下列步驟:

# Change NIC1 configure
vim /etc/sysconfig/network-scripts/ifcfg-eth0
# Amend the following lines in the "/etc/sysconfig/network-scripts/ifcfg-eth0" file.
DEVICE="eth0"
BOOTPROTO="none"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="no"
MASTER="bond0"
SLAVE="yes"
# Change NIC2 configure
vim /etc/sysconfig/network-scripts/ifcfg-eth1
# Amend the following lines in the "/etc/sysconfig/network-scripts/ifcfg-eth1" file.
DEVICE="eth1"
BOOTPROTO="none"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL="no"
MASTER="bond0"
SLAVE="yes"

[Load Kernel module]
接下來則是設定Bonding所需使用模組,於目錄:/etc/modprobe.d新增設定檔:bonding.conf,其內容資訊參閱下列步驟:

vim /etc/modprobe.d/bonding.conf
# Add or amend the following lines in the "/etc/modprobe.d/bonding.conf" file.
# alias bondN bonding
alias bond0 bonding

bondN的編號需與先前新增的設定檔:/etc/sysconfig/network-scripts/ifcfg-bond0編號一致

[Restart Network And Check Status]
重新啓動Network daemon即可生效:

/etc/init.d/network restart

下列步驟可觀察Bonding Module載入狀態:

[root@nagios-staging ~]# lsmod | grep -i bond
bonding               127060  0 
8021q                  25058  1 bonding
ipv6                  322541  50 bonding,ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6

使用ifconfig command可觀察Bonding使用狀態:

ifconfig bond0

下列步驟可查看現階段Bonding所運作的NIC及相關資訊:

[root@nagios-staging ~]# cat /proc/net/bonding/bond0

[Reference]
Channel Bonding Interfaces
Using Channel Bonding
Bonding in RHEL 6
Linux 網路結合(network bonding)技術與實務


上一篇
[Day28 - Linux] Lock User Accounts After Login Failure
下一篇
[Day30 - VMware] Enable Copy and Paste on a Virtual Machine
系列文
Linux及虛擬化平台維運分享27
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 則留言

0

我要留言

立即登入留言