Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize load balance of double Network Card in Linux

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to achieve dual network card load balancing in Linux, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

1. Game server:

1. Configuration:

Intel dual core CPU,

2GB667 memory,

SCSI146GB hard disk * 2 (hard disk speed: 15000 rpm / s) installs games + 80GBIDE

Intel 800003ES2LAN Gigabit Ethernet Gigabit Network Card * 2 (onboard)

Video card onboard

2. Operating system: Red Hat Enterprise Linux AS5

Kernel: kernel 2.6.18-8.e15

IDE80GB, specializing in linux operating system, 2 SCSI hard disk group hard arrays

2. PC:

1. Configuration:

AM2 4000 +,

1GB667 memory,

Serial port 160GB hard disk,

GF7600GT graphics card,

Realtek RTL 8169Comp8110 Gigabit Network Card

2. Operating system: Windows XP Service Pack2

Deadline for IE patch: November 8, 2007

3. Network environment:

1. Main switch, sub-switch, all Huawei 3C full gigabit switches

2, network cable, all more than six types of gigabit network cable, but the crystal head is a little bit, using a hundred megabit crystal head. -_. #

3. Network cable practice: 586B

How to achieve load balancing:

The first step is to edit the virtual network interface profile.

Create / etc/sysconfig/network-scripts/ifcfg-bond0 file

The contents are as follows:

DEVICE=bond0

IPADDR=192.168.0.253

NETMASK=255.255.252.0

BROADCAST=192.168.0.255

NETWORK=192.168.0.253

The second step is to edit the configuration file of the real network card (it is recommended to make a backup before modification) (I have two network cards here, so just do the following steps)

1. Edit the eth0 network card

Vi / etc/sysconfig/network-scripts/ifcfg-eth0

The contents are as follows:

DEVICE=eth0

BOOTPROTO=none

TYPE=Ethernet

MASTER=bond0

Slave=yes

2. Edit the eth2 network card

Vi / etc/sysconfig/network-scripts/ifcfg-eth2

The contents are as follows:

DEVICE=eth2

BOOTPROTO=none

TYPE=Ethernet

MASTER=bond0

Slave=yes

(note: the ip address of the real Nic can no longer be set. Press this setting for all the real NICs to be bound as needed, mainly because MASTER=bond0 and slave=yes must not be mistaken (the simple way is to modify one and copy it again)

The third step is to modify the / etc/modprobe.conf file and add the following two lines: (backup is recommended)

Alias bond0 bonding

Options bond0 miimon=100 mode=1

(note: 1. Miimon is the time interval for link monitoring in milliseconds. Miimon=100 means to detect the connection between the network card and the switch every 100ms, and if not, another link is used.

2. Mode=0 means load balancing, and both NICs work. Mode=1 means redundancy. There is only one Nic to work and one to enable the other if there is a problem.)

Step 4. Add the following line to / etc/rc.d/rc.local (execute this line at startup)

Ifenslave bond0 eth0 eth2

The fifth step, load balancing has worked normally after reboot.

- -

Test results:

1. Test speed of Linux game server:

1. Hard disk detection:

[root@ecofe2 ~] # fdisk-l

Disk / dev/hda: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/hda1 * 1 637 5116671 83 Linux

/ dev/hda2 638892 2048287 + 82 Linux swap / Solaris

/ dev/hda3 893 9729 70983202 + 83 Linux

Disk / dev/sda: 291.9 GB, 291999055872 bytes

255 heads, 63 sectors/track, 35500 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 35500 285153718 + 83 Linux

2. Read and write speed:

[root@ecofe2 ~] # hdparm-tT / dev/hda

/ dev/hda:

Timing cached reads: 7480 MB in 2.00 seconds = 4733.86 MB/sec

Timing buffered disk reads: 156 MB in 3.01 seconds = 51.75 MB/sec

[root@ecofe2 ~] # hdparm-tT / dev/sda

/ dev/sda:

Timing cached reads: 9476 MB in 2.00 seconds = 5519.36 MB/sec

Timing buffered disk reads: 740 MB in 3.00 seconds = 246.40 MB/sec

Second, client download speed:

1. Adopt mode=1 mode and connect to any network card

Use the client to download World of Warcraft with 7.62GB capacity. The download speed is the lowest 30MB/s, the highest 57MB/s, and the average 50MB/s.

2. In mode=0 mode, connect one network cable to any network card, or two network cables to two network cards

Use the client to download World of Warcraft with 7.62GB capacity. The download speed is the lowest 20MB/s, the highest 45MB/s, and the average 30MB/s.

3. One end adopts 568B method, the other uses 1-3, 2-6, 4-7, 5-8 line exchange, and adopts gigabit crystal head, and then adopts mode=1 mode to connect any network card.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report