Molet

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

Molet 运维技术 2022-11-15 454浏览 0

在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)

继续浏览有关 网络 的文章
发表评论