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

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

在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

#p#双网卡负载均衡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)

 

责任编辑:佟健 来源: 互联网
相关推荐

2010-04-20 12:42:54

负载均衡

2009-02-19 15:50:00

Linux双网卡绑定负载均衡

2010-04-20 17:34:21

Linux双网卡负载均衡

2009-11-30 17:40:13

Suse双网卡绑定

2018-05-03 14:12:57

部署环境步骤

2023-10-12 22:25:04

微服务Spring

2010-05-05 18:58:34

STP负载均衡

2021-11-29 05:26:11

软件测试开发软件工程

2018-04-18 21:55:59

多云架构云计算数据

2022-03-21 08:00:00

网络安全影子IT数据泄露

2023-08-02 16:39:28

数据治理

2024-03-04 11:07:27

云计算

2016-09-27 13:00:07

LibreOffice内存占用启动器

2009-04-02 10:14:00

VoIP服务质量QoS

2010-09-17 15:21:17

路由器TFTP配置

2022-09-30 14:59:30

Ubuntu

2022-07-01 13:56:41

云计算混合云迁移云

2010-05-10 18:11:24

负载均衡机

2010-12-17 17:46:54

负载均衡负载均衡配置

2022-02-23 15:09:18

数字化转型国有企业数据
点赞
收藏

51CTO技术栈公众号