In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Article Contents 1. Common Web Cluster Scheduler: 2. Haproxy Application Analysis: 3. Haproxy Scheduling Algorithm Principle: 4. Experimental Example: Step 1: Build Two Nginx Servers Step 2: Build Haproxy Step 3: Use Browser to Access Scheduling Server on Win10 (192.168.100.100/test.html) Step 4: Optimize the log I. Common Web cluster scheduler: At present, common Web cluster scheduler is divided into software and hardware. Software usually uses open source LVS, Haproxy, Nginx. Hardware is generally used more F5. Many people also use some domestic products, such as Barracuda, Green Alliance, etc. Second, Haproxy application analysis: (1) LVS has strong load resistance in enterprise applications, but it has shortcomings: LVS does not support regular processing, and cannot realize dynamic and static separation; for large websites, LVS implementation configuration is complex, and maintenance costs are relatively high.(2) Haproxy is a software that can provide high availability, Load Balancer, and proxy based on TCP and HTTP applications. It is especially suitable for Web sites with extremely heavy load. Running on the current hardware can support tens of thousands of concurrent connection requests III. Haproxy scheduling algorithm principle: Haproxy supports a variety of scheduling algorithms, the most commonly used are three: (1) RR: RR algorithm is the simplest and most commonly used algorithm, namely polling scheduling;
(2) LC: LC algorithm, i.e., the minimum number of connections algorithm, dynamically allocates front-end requests according to the number of connections of back-end nodes;
(3) SH: SH refers to the source-based access scheduling algorithm. The secondary algorithm is used for some scenarios where session records are recorded on the server side. Cluster scheduling can be done based on the source IP, Cookie, etc.
Four, experimental examples: (1) environmental preparation: two Nginx servers, a Haproxy scheduling server, a window as a test; write two test web pages in two Nginx servers; all host network cards are set to host-only mode, modify the network card information; the client can access two node servers by accessing the scheduling server, without accessing the real server address. Role IP address Haproxy 192.168.100.100Nginx 01 192.168.100.201Nginx 02 192.168.100.202window10 (as a test) 192.168.100.50
The first step: build two Nginx servers here the specific details are no longer written, you can see the previous blog, there are detailed writing process and details. After setting up the Nginx service, add a test homepage to the Nginx homepage html to verify the experimental results: The first one:
Second channel:
Step 2: Build Haproxy (1) Install compilation tools: yum install bzip2-devel pcre-devel gcc gcc-c++ make -y (2) You can mount the haproxy compression package locally by remote mount, and then decompress: tar zxvf haproxy-1.5.19.tar.gz-C /opt//Extract to/opt directory (3) Compile: make TARGET=linux3100 Note: This version number, you can use the uname -a command to view the version number
make install (4) Create a file and make backup modifications: mkdir /etc/haproxycp examples/haproxy. cfg/etc/haproxy/vim /etc/haproxy/haproxy.cfgglobal log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info maxconn 4096 uid 99 gid 99 daemon #debug #quietdefaults log global mode http option httplog option dontlognull retries 3 maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000listen webcluster 0.0.0.0:80 option httpchk GET /test.html balance roundrobin server inst1 192.168.100.201:80 check inter 2000 fall 3 server inst2 192.168.100.202: 80 check inter 2000 fall 3 (5) startup script: cp examples/haproxy.init /etc/init.d/haproxy //copy to init.d startup process chmod +x /etc/init.d/haproxy //add execution permissions chkconfig --add haproxy //add to service for easy identification ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy //create soft connection (6) start service: service haproxy start
Turn off firewall and other environments [root@Haproxy-1.5.19]# systemctl stop firewall.service [root@Haproxy-1.5.19]# setenforce 0 Step 3: Access scheduling server with browser on win7 (192.168.100.100/test.html)
Step 4: Optimize logs Optimize and modify the scheduler configuration file. Normal access information and error information can be stored in different log files for convenient management. Haproxy logs are output to syslog of the system by default, and are generally defined separately in production environment. (1) Modify the main configuration file vim/etc/haproxy/haproxy.cfg Modify the global section: log /dev/log local0 info The requested URL/dev/log was not found on this server. local0 notice //Where tips, warnings, etc. are stored
(2) Restart service haproxy (3) Create file, Add rule [root@Haproxy]# touch /etc/rsyslog.d/haproxy.conf[root@Haproxy]# cd /etc/rsyslog.d/[root@Haproxy rsyslog.d]# vim haproxy.conf if ($programname == 'haproxy' and $syslogseverity-text == 'info')then -/var/log/haproxy/haproxy-info.log&~if ($programname == 'haproxy' and $syseverity-text == 'note') then -/var/log/haproxy/haproxy-notice.log&~(4) Restart log service systemctl restart rsyslog.service (5) View log file: /var/log/haproxy/haproxy-info.log
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.