Haproxy 1.8 Rpm Spec File

Posted : admin On 07.09.2019

HAProxy is a very fast and reliable solution for high availability, load balancing, It supports TCP and HTTP-based applications. Now a days most of the websites need 99.999% uptime for their site, which are not possible with single server setup. Then we need some high availability environment which can easily manage with single server failure.

  1. Haproxy 1.8 Rpm Spec File Example

I'm building an rpm, I have a few requirements, a few of them aren't really working:Here's what I'm writing in the spec file:

When I'm trying to install the rpm using the following command:

I'm getting the following errors:

Output from rpm -qpR $myrpm

user3502786user3502786
1,2669 gold badges33 silver badges46 bronze badges

1 Answer

I believe your curl = curl-7.29.0-25.el7 entry shouldn't have curl on the right-hand side. It isn't part of the version string.

Your java-1.8.0-openjdk requirement appears to be missing the leading epoch value 1 (see 1:1.8.0.65-3.b17.el7 in the yum output). (Though I'm a bit surprised if you actually need to include that.)

Similarly shawdow-utils appears to be missing the leading 2 epoch (see 2:4.1.5.1-18.el7 in the yum output).

That all said being so incredibly specific in your requirements is likely a bad idea. It means you won't be able to update any of those packages while your package is installed (without rebuilding it) even if, as is likely, whatever you are packaging would work with updated versions just fine.

Etan ReisnerEtan Reisner
60.4k5 gold badges56 silver badges93 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged rpmpackagingrpmbuildrpm-spec or ask your own question.

On this page

  1. Basic Concept with HAProxy

HAProxy or High Availability Proxy is an open source TCP and HTTP load balancer and proxy server software. HAProxy has been written by Willy Tarreau in C, it supports SSL, compressions, keep-alive, custom log formats and header rewriting. HAProxy is a fast and lightweight proxy server and load balancer with a small memory footprint and low CPU usage. It is used by large sites like Github, StackOverflow, Reddit, Tumblr, Twitter and others. It has become the most popular software load balancer and proxy server in the past years.

In this tutorial, I will guide you trough the HAProxy installation and configuration for 3 servers, one load balancer, and two Nginx web servers. We will install HAProxy on a single server and then install Nginx web server on the other servers. HAProxy acts as a load balancer for the Nginx web servers.

Basic Concept with HAProxy

Layer 4 and Layer 7

HAProxy can run in two modes: TCP mode Layer 4 and HTTP Mode Layer 7. In Layer 4 TCP mode, HAProxy forwards the RAW TCP packets from the client to the application servers. In the Layer 7 HTTP mode, HAProxy is parsing the HTTP header before forwarding them to the application servers. In this tutorial, we will use Nginx as the web server that only supports the Layer 7 HTTP mode.

Balance Algorithm

This is the algorithm that is used by HAProxy to select the server when doing the load balancing. The following modes are available:

Roundrobin

This is the most simple balance algorithm. For each new connection, it will be handled by the next backend server. If the last backend server in the list is reached, it will start again from the top of backend list.

Lastconn

The new connection will be handled by the backend server with least amount of connections. This is useful when the time and load of the requests vary a lot.

Source

This is for sticky sessions, the client IP will be hashed to determine the backend server that received the last request from this IP. So an IP A will always be handled by backend1, and IP B will always be handled by banckend2 to not interrupt sessions

There are oOther algorithm - check the official HAProxy site for details.

Prerequisites

  • 3 CentOS 7

loadbalancer
192.168.1.102
nginx1
192.168.1.104
nginx2
192.168.1.105

  • Root privileges on all 3 servers.
Haproxy

Step 1 - Configure the /etc/hosts files

Log in to the load balancer server and edit the /etc/hosts file.

It can let you update or not the download application as your desire.What is Internet Download Manager?Internet download manager is a software which is very popular. You can use the key so that you can access the Internet download manager free as a premium and paid user. Internet Download Manager is simple, but at the same time allows you to set several options for its management. It allows you to download files in a simple, fast and automated way as well as his older platforms also from Hosting sites with login credentials. Idm serial number 6.28.

Add nginx1 and nginx2 hostnames:

Save the file and exit the editor.

Next, edit the hosts file on the Nginx servers (nginx1 and nginx2):

Rpm

Edit and add a new line for the load balancer in the hosts files:

Add the loadbalancer hostname on each nginx server:

do this on nginx1 and nginx2 server.

Step 2 - Install and Configure HAProxy

HAProxy is available in the CentOS 7 repository, log in to the loadbalancer server and update the package lists:

Now install HAProxy with this yum command:

1.8

When the installation is finished, go to the '/etc/haproxy/' directory and backup the original configuration file:

Next, add a new HAProxy configuration file 'haproxy.cfg' file with the vi editor:

Paste the configuration below:

Save the configuration file and exit.

Next, configure rsyslog for HAProxy.

We will configure the rsyslog daemon to log the HAProxy statistics. Edit the rsyslog.conf file to enable the UDP port 514 to be used by rsyslog.

Uncomment this line to enable the UDP connection:

If you want to use a specific IP, you can add a new line like the one below:

Save the file and exit.

Then create new haproxy configuration file for rsyslog:

Paste configuration below:

Haproxy 1.8 Rpm Spec File Example

Save and exit.

Now restart rsyslog and then start the haproxy:

Add haproxy to start at boot time:

Step 3 - Install and Configure Nginx

In this section, we will install Nginx from epel repository on nginx1 and nginx2 server.

Log in to the servers:

Install the epel repository with the yum command below:

Now you can install Nginx:

Nginx is installed. Go to the web directory and change the index file so that we can see which of the two servers delivered the html file:

Next, add Nginx to start at boot time and then start it:

Make sure you're doing this step on nginx1 and nginx2 server.

Step 4 - Testing

Testing from browser by accessing the loadbalancer IP: 192.168.1.102

Testing with curl command:

Testing to login to the HAProxy web monitoring that is running on port 8080 with username and password 'howtoforge':

http://192.168.1.102:8080/stats

HAProxy is working successfully and acts as a load balancer for our two Nginx web servers.

Conclusion

HAProxy or High Availability proxy is an open source software that provides high availability for TCP-based services, it operates as HTTP load balancer and proxy server. The software is written in C and supports SSL, keep-alive and compression. HAProxy is the right choice for everyone who needs a load balancer and proxy server that is fast and lightweight with a small memory footprint and low CPU usage. Haproxy can run in Layer 4 TCP mode and Layer 7 HTTP mode. Nginx supports only the Layer 7 HTTP mode with HAProxy. If you want to use Layer 4 TCP mode, you can use other web servers like apache. On CentOS 7, HAProxy is available in the default repository. It's easy to install and configure.