Linux Cluster Server Load balancer lab notes

Source: Internet
Author: User
 

Linux Cluster Server Load balancer lab notes

I,Network Topology:


II,Virtual Machine Configuration

Create three virtual machines on one physical computer.WindowsOperating System, Configuration192.168.1.0The IP address of the CIDR block.Centos5.4. One Server Load balancer instance must be configured with two NICs. The other two servers only need one NIC ANDHttpd.

A)Server Load balancer Configuration

The first Nic Configuration:

# Advanced Micro Devices [amd] 79c970 [pcnet32 Lance]

Device = eth0

Bootproto = static

Broadcast = 192.168.1.255

Hwaddr = 00: 0C: 29: 57: 28: 8E

Ipaddr = 192.168.1.12

Netmask = 255.255.255.0

Network = 192.168.1.0

Gateway = 192.168.1.1

Onboot = Yes

The second Nic Configuration:

# Advanced Micro Devices [amd] 79c970 [pcnet32 Lance]

Device = eth1

Bootproto = static

Broadcast = 192.168.11.255

Hwaddr = 00: 0C: 29: 57: 28: 89

Ipaddr = 192.168.11.1

Netmask = 255.255.255.0

Network = 192.168.11.0

Onboot = Yes

B)Implement Server Configuration

First ServerWebNic Configuration:

# Advanced Micro Devices [amd] 79c970 [pcnet32 Lance]

Device = eth0

Bootproto = static

Broadcast = 192.168.1.255

Hwaddr = 00: 0C: 29: 57: 28: 82

Ipaddr = 192.168.11.2

Netmask = 255.255.255.0

Network = 192.168.11.0

Gateway = 192.168.11.1

Onboot = Yes

Second ServerWebNic Configuration:

# Advanced Micro Devices [amd] 79c970 [pcnet32 Lance]

Device = eth0

Bootproto = static

Broadcast = 192.168.1.255

Hwaddr = 00: 0C: 29: 57: 28: 84

Ipaddr = 192.168.11.3

Netmask = 255.255.255.0

Network = 192.168.11.0

Gateway = 192.168.11.1

Onboot = Yes

Note:MacDifferent. Fill in according to the actual situation. If the VM Nic is started, refer:Http://hi.baidu.com/wxlccsu/blog/item/f58b4acf2c09b5400eb34561.html

III,Implementation Configuration

1, On the server Load balancer

# Yum-y install ipvsadm (Check the network orYumSource)

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Addons | 951 B 00: 00
Base | 2.1 kb
Extras | 2.1 kb: 00
Mod-pagespeed | 951 B
Update | 1.9 kb: 00
Setting up install process
Resolving Dependencies
There are unfinished transactions remaining. You might consider running Yum-complete-transaction first to finish them.
The program Yum-complete-transaction is found in the Yum-utils package.
--> Running transaction check
---> Package upgrade SADM. i386. 24-10 set to be updated
--> Finished dependency resolution

Dependencies resolved

=================================================== ========================================================== ==
package arch version repository size
=================================================== ========================================================== ==
installing:
ipvsadm i386 1.24-10 Base 31 K

Transaction Summary
========================================================== ==========================================================
Install 1 package (s)
Upgrade 0 package (s)

Total download size: 31 K
Downloading packages:
Ipvsadm-1.24-10.i386.rpm | 31 KB 00:01
Running rpm_check_debug
Running transaction Test
Finished transaction Test
Transaction test succeeded
Running transaction
Installing: ipvsadm 1/1

Installed:
Ipvsadm. i386. 24-10

Complete!

# Sysctl-W net. ipv4.ip _ forward = 1Enable Routing

# Ipvsadm-CClear the original Cluster Policy

# Ipvsadm-a-t 192.168.1.12: 80-s RR //-Add a cluster,-T TCPProtocol,-SAlgorithm

# Ipvsadm-l n //View cluster members

IP Virtual Server version 1.2.1 (size = 4096)
Prot localaddress: Port sched1_flags
-> Remoteaddress: port forward weight activeconn inactconn
TCP 192.168.1.10: 80 rr

# Ipvsadm-a-t 192.168.1.12: 80

//-Add oneRealServer-T TCPProtocolOfIP-mAddress disguiseNumber of hits

# Ipvsadm-a-t 192.168.1.12: 80-r 192.168.11.3: 80-m-W 1

# Ipvsadm-l n //View cluster members again

IP Virtual Server version 1.2.1 (size = 4096)
Prot localaddress: Port sched1_flags
-> Remoteaddress: port forward weight activeconn inactconn
TCP 192.168.1.10: 80 rr
-> 192.168.11.3: 80 masq 1 0 0
-> 192.168.11.2: 80 masq 1 0 0

Or directly configure the file

# Vi/etc/sysconfig/ipvsadm
Add the following content:
-A-T 192.168.1.12: 80-s rr
-A-T 192.168.1.12: 80-r 192.168.11.2: 80-m-W 1
-A-T 192.168.1.12: 80-r 192.168.11.3: 80-m-W 1

The first is the VIP address and the load balancing algorithm.
-S parameter: select the Server Load balancer Algorithm
* Round-round scheduling rr
* Weighted Round Scheduling (weightedround-scheduling) WRR
* Least-connectionscheduling LCs
* Weightedleast-connectionscheduling wlc
* Locality-basedleastconnectionsscheduling LLCs
* Locality-basedleastconnectionswithreplicationscheduling llcrs
* Destinationhashingscheduling (DHS)
* Source Address hash Scheduling (sourcehashingscheduling)
Add nodes later
-W parameter is the weight of each node
Start ipvsadm
#/Etc/init. d/ipvsadmrestart

2, In twoWebStart simultaneously on the serverHttpdService

#/Etc/init. d/httpd start

On the first Server

# Cd/var/www/html/

# Echo "This is realserv 1"> index.html

On the second Server

# Cd/var/www/html/

# Echo "This is realserv 2"> index.html

IV,Test

InWindowsEnter192.168.1.12The browser is displayed first."This is realserv 1 ",After refresh,"This is realserv 2"

NOTE: If ipvsadm is the source code, the system kernel version should be taken into account. Find the source code installation package that matches the kernel version. :Http://www.linuxvirtualserver.org/software/ipvs.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.