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 WEB load balancing with Red Hat Piranha Scheme

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Red Hat Piranha solution how to achieve WEB load balancing, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail, people with this need can come to learn, I hope you can gain something.

System environment:

RHEL6.5x86_64 small install selinux and iptables disabled

Virtual IP 192.168.2.253

192.168.2.162 server62.exampl.com (primary node)

192.168.2.163 server63.example.com (standby node)

192.168.2.52 desktop52.example.com (real server)

192.168.2.53 desktop53.example.com (real server)

Edit / etc/hoststs to do the above parsing

one。 The Piranha scheme is basically introduced briefly.

1. Advantages of Piranha solution:

1.1 configuration is simple and efficient:

Simple configuration can be done with a lvs.conf configuration file (keepalived-like scheme.)

1.2 WEB configuration interface.

WEB configuration is very attractive to those who do not understand LVS configuration. It only takes you 15 minutes to configure a load balancer and high availability solution.

1.3 full functionality:

Heartbeat and HA (pulse, send_arp) of LVS (Load Balancer) and Heartbeat (nanny) of process service between Load Balancer and Real Server

* IPVS function (lvsd)

* Management of IPVS (ipvsadm)

2. Principle and structure description of Piranha solution:

Piranha is a highly available solution for load balancing based on LVS. LVS runs on a pair of computers with similar configurations:

One as the active LVS Router (Active LVS Router) and one as the backup LVS Router (Backup LVS Router).

The active LVS Router service has two roles:

* load balancing to real servers.

* check whether the service provided by the real server is normal.

Backup LVS Router is used to monitor the active LVS Router in case the active LVS Router fails to be taken over by the backup LVS Router.

Pulse:

The Pulse process runs on both the active LVS Router and the backup LVS Router. On the backup LVS Router, pulse sends a heartbeat (heartbeat) to the public network interface of the active LVS Router to check whether the active LVS Router is normal.

On the active LVS Router, the pulse starts the lvs process and responds to the heartbeat from the backup LVS Router.

Lvsd:

The lvs process invokes the ipvsadm tool to configure and maintain the IPVS routing table and starts a nanny process for each virtual service on the real server.

Nanny:

Each nanny process checks the status of the virtual service on the real server and notifies the lvs process of the failure. If a fault is discovered, the lvs process tells ipvsadm to delete the node from the IPVS routing table.

Send_arp:

If the backup LVS Router does not receive a response from the active LVS Router, it will call send_arp to reassign the virtual IP address to the public network interface of the backup LVS Router. And send a command on the public network interface and the local area network interface to shut down the lvs process on the active LVS Router. At the same time, start your own lvs process to schedule client requests.

3. Install the basic suite of Piranha solution:

# yum install ipvsadm modcluster piranha system-config-cluster php php-cli php-common

4. Profile description:

/ etc/sysconfig/ha/lvs.cf / / the configuration file configured by the http://ip:3636 web interface is written to this file.

/ etc/init.d/piranha-gui start / / start the WEB configuration interface of the piranha service.

/ etc/init.d/pulse / / what starts the piranha service to read is / etc/sysconfig/ha/lvs.cf.

two。 Piranha configuration

Configure the Piranha service through the WEB interface.

# / etc/init.d/piranha- gui start / / start the Piranha service.

# / usr/sbin/piranha- passwd / / to set the password, please set your piranha service WEB configuration login password.

Http://192.168.2.162:3636 / / enter the user name: piranha and the password just set to log in.

After logging in, select Global Settings. This is the configuration of LVS.

Enter the public network IP:192.168.2.162 for Primary server public IP, and press the ACCEPT button to save the settings after application.

Configure the information of the primary LVS through WEB

1. Configure the primary LVS

two。 Configure backup LVS

3. Configure to add LVS (VIP information)

4. Configure Realserver

Start the node

5. Start the LVS service pulse

# / etc/init.d/pulse start

Starting pulse: [OK]

If the error is not reported, it means that the startup is successful!

The server to this LVS has been configured to start two programs.

1. Piranha-gui is used to configure LVS

2. Pulse is used to start LVS

6. Backup LVS installation and configuration

Backup LVS installation is the same as the main LVS installation method. Copy the lvs.conf directly to the appropriate directory:

# scp / etc/sysconfig/ha/lvs.cf root@192.168.2.163:/etc/sysconfig/ha/

# / etc/init.d/pulse start just start the service.

7. Configure Realserver

# yum install-y arptables_jf

# ifconfig eth0:1 192.168.2.253 netmask 255.255.255.255

# arptables-An IN-d 192.168.2.253-j DROP

# arptables-An OUT-s 192.168.2.253-j mangle--mangle-ip-s 192.168.2.53

# service arptables_jf save

The above actions will automatically generate the file / etc/sysconfig/arptables

# cd / var/www/html/ enter the default Apache release directory

# echo `hostname` > index.html

# service httpd start / / start Apache service

Test:

1)。 Visit the virtual ip to see if you can access the httpd services of the two realserver nodes. The refresh page displays different contents, indicating that the rotation cycle has been realized.

2)。 Stop the pulse service of the load primary node, and the standby node automatically takes over the task.

3)。 Alternately stop or all stop the two realserver httpd services to check the changes in the forwarding list.

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

Development

Wechat

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

12
Report