In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Haproxy web cluster deployment
HAProxy provides high availability, load balancing, agents based on TCP and HTTP applications, and supports virtual hosts. It is a free, fast and reliable solution. HAProxy is especially suitable for heavily loaded web sites, which usually require session persistence or seven layers of processing. HAProxy implements a single-process model that supports a very large number of concurrent connections with multiple processes or multithreaded models that are limited by memory, system schedulers, and ubiquitous locks, and rarely handle thousands of concurrent connections.
Deployment environment:
Mainframe
IP address
Hostnam
Software
Operating system
Haproxy server
192.168.1.10
Haproxy
Haproxy-1.4.24
Centos-6.5
Nginx1 server
192.168.1.20
Nginx1
Nginx-1.6.2
Centos-6.5
Nginx2 server
192.168.1.30
Nginx2
Nginx-1.6.2
Centos-6.5
Client
192.168.1.40
Khj
IE browser
Centos-6.5
Compile, install, test nginx
Modify the ip address to remove the yum repository, and set up a new local yum repository below to create nginx package storage files
Mount the nginx CD cp to / nginx
Build a local yum warehouse
Yum file nginx.repo content:
Enter the / nginx directory to create a nginx user name for the tar nginx package
Compile and install nginx
Set up a test nginx page, start the nginx service, and see if the nginx port is started
Set iptables firewall policy to allow port 80 to pass through
Note: configuring the nginx1 server is the same as the nginx2 configuration above. You can follow the steps above.
Use the client to access two nginx servers
Compile and install haproxy
Set up a local yum repository to install haproxy dependency packages
Tar haproxy package, compiling and installing
TARGET=linux26 stands for 64-bit operating system
Establish a haproxy profile
Configuration haproxy server file configuration file is mainly divided into global global configuration, defaults default configuration, listen application component configuration.
Configure haproxy files, create self-startup scripts, set up soft connections
The haproxy.cfg configuration file is as follows:
Global
Log 127.0.0.1 local0 configures logging. Local0 is a logging device and is stored in the system log by default.
Log 127.0.0.1 local1 notice notice is the log level, usually 24 levels
# log loghost local0 info
Maxconn 4096 maximum number of connections
# chroot / usr/share/haproxy
Uid 99 user uid
Gid 99 user uid
Daemon
# debug
# quiet
Defaults
Log global definition logs are defined for logs in the globel configuration
Mode http mode is http
Option httplog records logs in http log format
Option dontlognull
Retries 3 checks the number of node failures, reaching three failures in a row, and will consider the node unavailable
Maxconn 2000 maximum number of connections
Contimeout 5000 connection timeout
Clitimeout 50000 client timeout
Srvtimeout 50000 server timeout
Option httpclose
Listen webcluster 0.0.0.0 80 defines a webcluster application
Option httpchk GET / index.html checks the server's index.html
Balance roundrobin load balancing scheduling algorithm using polling algorithm
Online node defined by server inst1 192.168.1.20 fall 80 check inter 2000 fall 3
Server inst2 192.168.1.30 fall 80 check inter 2000 fall 3 becomes a backup node if you add bachak after it
Start the haproxy service, turn off the firewall, or configure policy
Test whether the web cluster achieves high performance and high availability on the client (disable nginx1)
Configure haproxy Lo
The log of Haproxy is saved to the syslog of the system by default, which is not convenient to view, so we can store the log in different files separately in the production environment. The configuration is as follows
First of all, modify the configuration file, mainly change the following part
Then modify the rsyslog configuration, define the haproxy-related configuration to haproxy.conf independently, and put it under / etc/rsyslog.d. When rsyslog starts, it will automatically load all configuration files in this directory.
The configuration is as follows:
If ($programname = = 'haproxy' and $syslogseverity-text = =' info') then-/ var/log/haproxy/haproxy-info.log
$~
If ($programname = = 'haproxy' and $syslogseverity-text = =' notice') then-/ var/log/haproxy/haproxy-notice.log
$~
Restart the rsyslog service and view haproxy access information
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.