|
|
51CTO旗下网站
|
|
移动端

四个步骤完成双网卡负载均衡

文章摘要:如何完成双网卡负载均衡呢?我们将为大家展示linux系统下的设置过程,希望大家从文中能总结出方法,此文仅供参考。

作者:佚名来源:互联网|2010-05-06 12:25

在linux下实现负载均衡我们已经对它的配置说过很多了,现在我们介绍的是关于在这个系统下的双网卡负载均衡的设定过程,总的可以分为四个步骤,首先我们要对虚拟网络接口文件进行改动,然后是对网卡的信息文件的改动,之后是两个文件的编辑。

双网卡负载均衡1:

建立虚拟网络接口ifcfg-bond0文件

[root@yangwenjun ~]# cd /etc/sysconfig/network-scripts/
[root@yangwenjun network-scripts]# cp ifcfg-eth0 ifcfg-bond0
其内容为:
[root@yangwenjun network-scripts]# more ifcfg-bond0
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=bond0
BROADCAST=192.168.1.255
IPADDR=192.168.1.3
NETMASK=255.255.255.0
NETWORK=192.168.1.0
MTU=1500
GATEWAY=192.168.1.1
[root@yangwenjun network-scripts]#


双网卡负载均衡2:

编辑原有网卡eth0和eth信息文件,使其内容为:

[root@yangwenjun network-scripts]# more ifcfg-eth0
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
slave=yes
[root@yangwenjun network-scripts]# more ifcfg-eth1
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
slave=yes
[root@yangwenjun network-scripts]#

双网卡负载均衡3:

编辑/etc/modprobe.conf加入下面两行

[root@yangwenjun network-scripts]# vi /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=1
加入后我的modprobe.conf内容为:
[root@yangwenjun network-scripts]# more /etc/modprobe.conf
alias eth0 bnx2
alias eth1 bnx2
alias scsi_hostadapter aacraid
alias scsi_hostadapter1 ata_piix
alias peth0 bnx2
alias bond0 bonding
options bond0 miimon=100 mode=1

双网卡负载均衡4:

编辑/etc/rc.d/rc.local文件,加入ifenslave bond0 eth0 eth1;重新启动后,负载均衡就能正常工作了,可以用ifconfig查看具体信息

[root@yangwenjun network-scripts]# ifconfig
bond0   Link encap:Ethernet   HWaddr 00:1A:64:6A:55:98
 inet addr:192.168.1.3   Bcast:192.168.1.255   Mask:255.255.255.0
 inet6 addr: fe80::21a:64ff:fe6a:5598/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST   MTU:1500   Metric:1
 RX packets:985369 errors:0 dropped:0 overruns:0 frame:0
 TX packets:804306 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:148943796 (142.0 MiB)   TX bytes:2097755332 (1.9 GiB)

eth0  Link encap:Ethernet   HWaddr 00:1A:64:6A:55:98
 inet6 addr: fe80::21a:64ff:fe6a:5598/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST   MTU:1500   Metric:1
 RX packets:984133 errors:0 dropped:0 overruns:0 frame:0
 TX packets:804292 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:148805154 (141.9 MiB)   TX bytes:2097751381 (1.9 GiB)

eth1  Link encap:Ethernet   HWaddr 00:1A:64:6A:55:98
 inet6 addr: fe80::21a:64ff:fe6a:5598/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST   MTU:1500   Metric:1
 RX packets:1236 errors:0 dropped:0 overruns:0 frame:0
 TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:138642 (135.3 KiB)   TX bytes:4275 (4.1 KiB)
 Interrupt:16 Memory:ca000000-ca011100

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:24 errors:0 dropped:0 overruns:0 frame:0
 TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:1680 (1.6 KiB)   TX bytes:1680 (1.6 KiB)

peth0  Link encap:Ethernet   HWaddr FE:FF:FF:FF:FF:FF
 inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
 UP BROADCAST RUNNING NOARP   MTU:1500   Metric:1
 RX packets:984026 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1657683 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:152730203 (145.6 MiB)   TX bytes:2150908601 (2.0 GiB)
 Interrupt:21 Memory:ce000000-ce011100

vif0.0  Link encap:Ethernet   HWaddr FE:FF:FF:FF:FF:FF
 inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
 UP BROADCAST RUNNING NOARP   MTU:1500   Metric:1
 RX packets:804296 errors:0 dropped:0 overruns:0 frame:0
 TX packets:984134 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:2097747314 (1.9 GiB)   TX bytes:148805214 (141.9 MiB)

xenbr0  Link encap:Ethernet   HWaddr FE:FF:FF:FF:FF:FF
 UP BROADCAST RUNNING NOARP   MTU:1500   Metric:1
 RX packets:1532 errors:0 dropped:0 overruns:0 frame:0
 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:132808 (129.6 KiB)   TX bytes:0 (0.0 b)

【责任编辑:佟媛微 TEL:(010)68476606】

点赞 0
分享:
大家都在看
猜你喜欢

订阅专栏+更多

笑熬浆糊之职场那些事

笑熬浆糊之职场那些事

IT人的职场心法
共22章 | Bear_Boss

62人订阅学习

Redis运维秘籍

Redis运维秘籍

运维标配技术
共15章 | one叶孤舟

133人订阅学习

活学活用 Ubuntu Server

活学活用 Ubuntu Server

实战直通车
共35章 | UbuntuServer

247人订阅学习

读 书 +更多

程序员密码学

《程序员密码学》涉及密码学的各个研究方向,分组密码、散列函数、公钥密码以及相关的攻击,同时也讲解了密码学算法实现上常用的ASN.编码、...

订阅51CTO邮刊

点击这里查看样刊

订阅51CTO邮刊

51CTO服务号

51CTO播客