linux内核端口绑定,linux 多网卡bonding 绑定 端口聚合
將多個(gè)Linux網(wǎng)絡(luò)端口綁定為一個(gè),可以提升網(wǎng)絡(luò)的性能,比如對于備份服務(wù)器,需要在一個(gè)晚上備份幾個(gè)T的數(shù)據(jù),
如果使用單個(gè)的千兆網(wǎng)口將會是很嚴(yán)重的瓶頸。其它的應(yīng)用,比如ftp服務(wù)器,高負(fù)載的下載網(wǎng)站, 都有類似的問題。
因此使用Linux teaming或bond來綁定多個(gè)網(wǎng)卡作為一個(gè)邏輯網(wǎng)口,配置單個(gè)的IP地址,會大幅提升服務(wù)器的網(wǎng)絡(luò)吞吐(I/O)。
Linux的多網(wǎng)卡綁定功能使用的是內(nèi)核中的"bonding"模塊,關(guān)于此模塊可以參考Linux Ethernet Bonding Driver文檔,
但是目前發(fā)布各個(gè)Linux版本內(nèi)核均已包含了此模塊,大多數(shù)情況下不需要重新編譯內(nèi)核。
Linux 的 bonding 驅(qū)動提供了綁定/集成(bond)多個(gè)網(wǎng)卡為一個(gè)虛擬邏輯網(wǎng)口的功能。并請注意綁定的網(wǎng)口(bonded)有多種工作模式;
一般來說,分為 熱后備(hot standby) 和 負(fù)載均衡(load balancing). 在Redhat/Fedora和其它類Redhat Linux中是比較容易配置的。
1.創(chuàng)建bond0配置文件
vi /etc/sysconfig/network-scripts/ifcfg-bond0
[root@localhost network-scripts]# less ifcfg-bond0
DEVICE=bond0
#HWADDR=00:10:18:D8:62:58
TYPE=Ethernet
#UUID=85f545ec-5add-48e0-bcc6-3699a2202972
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=192.168.2.10
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
MTU=9000
BONDING_OPTS="mode=4 miimon=100"
2.修改被綁定的eth0和eth1的配置文件
[root@localhost network-scripts]# cat ifcfg-eth2
DEVICE=eth2
HWADDR=00:10:18:D8:62:58
TYPE=Ethernet
UUID=85f545ec-5add-48e0-bcc6-3699a2202972
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
MTU=9000
[root@localhost network-scripts]# cat ifcfg-eth3
DEVICE=eth3
#HWADDR=00:10:18:D8:62:58
TYPE=Ethernet
UUID=85f545ec-5add-48e0-bcc6-3699a2202972
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
MTU=9000
[root@localhost network-scripts]# cat ifcfg-eth4
DEVICE=eth4
#HWADDR=00:10:18:D8:62:58
TYPE=Ethernet
UUID=85f545ec-5add-48e0-bcc6-3699a2202972
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
MTU=9000
[root@localhost network-scripts]# cat ifcfg-eth5
DEVICE=eth5
#HWADDR=00:10:18:D8:62:58
TYPE=Ethernet
UUID=85f545ec-5add-48e0-bcc6-3699a2202972
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
MTU=9000
3.裝在bond模塊驅(qū)動
編輯/etc/modprobe.conf或者/etc/modules.conf文件,加入如下內(nèi)容,使系統(tǒng)啟動時(shí)加載bonding模塊驅(qū)動
如果沒有modprobe.conf 就vi modprobe.conf 一個(gè)文件
alias bond0 bonding
option bond0 miimon=100 mode=1
說明:
1).miimon=100 用來進(jìn)行鏈路監(jiān)測的。即每100ms監(jiān)測一次鏈路狀態(tài)。bonding只監(jiān)測主機(jī)與交換機(jī)之間鏈路。如果交換機(jī)出去的鏈路出問題而本身沒有問題,那么bonding認(rèn)為鏈路沒有問題而繼續(xù)使用。
2).mode=1 表示提供冗余功能。除此之外還可以為0、2、3,共四種模式。0表示負(fù)載均衡
4.在/etc/rc.d/rc.local文件中加入如下語句,使得系統(tǒng)啟動自動運(yùn)行
ifenslave bond0 eth0 eth1
route add -net 192.168.1.254 netmask 255.255.255.0 bond0 #如有需要才加該路由
5.檢測、驗(yàn)證配置
首先執(zhí)行命令裝載bonding模塊:modprobe bonding
重啟網(wǎng)絡(luò)服務(wù),并確認(rèn)bond0正確啟動:service network restart
確認(rèn)設(shè)備已經(jīng)正確加載:less /proc/net/bonding/bond0
[root@localhost network-scripts]# less /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
802.3ad info
LACP rate: slow
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
Aggregator ID: 15
Number of ports: 1
Actor Key: 17
Partner Key: 1
Partner Mac Address: 00:00:00:00:00:00
Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 5
Permanent HW addr: 00:10:18:d8:62:58
Aggregator ID: 12
Slave queue ID: 0
Slave Interface: eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:10:18:d8:62:5a
Aggregator ID: 13
Slave queue ID: 0
Slave Interface: eth4
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:10:18:d8:62:5c
Aggregator ID: 14
Slave queue ID: 0
Slave Interface: eth5
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:10:18:d8:62:5e
Aggregator ID: 15
Slave queue ID: 0
至此,bond 的設(shè)置就基本結(jié)束了
總結(jié)
以上是生活随笔為你收集整理的linux内核端口绑定,linux 多网卡bonding 绑定 端口聚合的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dt程序网站服务器配置,ZKWeb 官网
- 下一篇: linux 其他常用命令