当前位置:网站首页>Hapoxy cluster service setup
Hapoxy cluster service setup
2022-06-23 17:26:00 【User 7353950】
Hapoxy colony
1. Hapoxy brief introduction
HAProxy It's a use C Free and open source software written in language [1], It provides high availability 、 Load balancing , And based on TCP and HTTP Application proxy for .
HAProxy Especially suitable for those with heavy load web Site , These sites usually need session persistence or seven layers of processing .HAProxy Running on the current hardware , It can support tens of thousands of concurrent connections . And its running mode makes it easy and safe to integrate into your current architecture , And protect your web The server is not exposed to the network .
HAProxy Implemented an event driven , Single process model , This model supports a very large number of concurrent connections . The multiprocess or multithreaded model is limited by memory 、 System scheduler restrictions and ubiquitous lock restrictions , Rarely handle thousands of concurrent connections . Event driven model because of better resource and time management of user space (User-Space) Achieve all of these tasks , So there are no such problems . The disadvantage of this model is , On a multicore system , These programs usually have poor scalability . That's why they have to optimize to Make each CPU Time slice (Cycle) Do more work .
Include GitHub、Bitbucket[3]、Stack Overflow[4]、Reddit、Tumblr、Twitter5 and Tuenti[7] Famous websites inside , And Amazon Web services HAProxy.
haproxy_ Baidu Encyclopedia (baidu.com)
2. Haproxy The construction of clusters
2.1 Environment configuration
Service configuration | ip |
|---|---|
Haproxy | 192.168.80.20 |
web The server 1 | 192.168.80.30 |
web The server 2 | 192.168.80.35 |
2.2 The configuration process
1. Turn off firewall , And transmit compressed packets
systemctl stop firewalld
setenforce 0
haproxy-1.5.19.tar.gz2. Compilation and installation Haproxy
yum install -y pcre-devel bzip2-devel gcc gcc-c++ make
tar zxvf haproxy-1.5.19.tar.gzcd haproxy-1.5.19/
make TARGET=linux2628 ARCH=x86_64
make install3.Haproxy Server configuration
mkdir /etc/haproxy
cp examples/haproxy.cfg /etc/haproxy/
cd /etc/haproxy/
vim haproxy.cfg
_______________________________
global
--4~5 That's ok -- modify , Configure logging ,local0 For log devices , It is stored in the system log by default
log /dev/log local0 info
log /dev/log local0 notice
#log loghost local0 info
maxconn 4096 # maximum connection , Need to consider ulimit -n Limit
--8 That's ok -- notes ,chroot Running path , Self set root directory for the service , Generally, this line needs to be commented out
#chroot /usr/share/haproxy
uid 99 # user UID
gid 99 # user GID
daemon # Daemons mode
defaults
log global # Define the log as global Log definition in configuration
mode http # The model is http
option httplog # use http Log format log
option dontlognull # Do not record health check log information
retries 3 # Check node server failures , Three consecutive failures , The node is considered unavailable
redispatch # When the server load is high , Automatically end connections that have been queued for a long time
maxconn 2000 # maximum connection
contimeout 5000 # Connection timeout
clitimeout 50000 # Client timeout
srvtimeout 50000 # Server timeout
-- Delete all below listen term --, add to
listen webcluster 0.0.0.0:80 # Define a name webcluster Application
option httpchk GET /index.html # Check the... Of the server test.html file
balance roundrobin # The load balancing scheduling algorithm uses the polling algorithm roundrobin
server inst1 192.168.80.30:80 check inter 2000 fall 3 # Define online nodes
server inst2 192.168.80.35:80 check inter 2000 fall 34. Add system services
cp /opt/haproxy-1.5.19/examples/haproxy.init /etc/init.d/haproxycd /etc/init.dchmod +x haproxy
chkconfig --add /etc/init.d/haproxyln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
service haproxy start or /etc/init.d/haproxy start2.3 Configuration screenshot
2.3.1haproxy Server configuration
2.3.2 Web Server node configuration
————————————————————————————192.168.80.30 To configure echo "this is WEB SERVER11111" > /var/www/html/index.html
systemctl start httpd
————————————————————————————192.168.80.35 To configure echo "this is WEB SERVER22222" > /var/www/html/index.html
systemctl start httpd2.3.3 Client access test
3. Haproxy Cluster log redefinition
haproxy The log of is output to the system by default syslog in , In the previous step, the logs have been defined in /dev/log in , Pictured
Need modification rsyslog To configure , For ease of management . take haproxy The relevant configuration is defined independently to haproxy.conf, And on the /etc/rsyslog.d/ Next ,rsyslog All configuration files in this directory will be loaded automatically at startup .
## This part of the configuration will haproxy Of info The log goes to /var/log/haproxy/haproxy-info.log Next , take notice The log goes to /var/log/haproxy/haproxy-notice.log Next .“&~” Indicates that after the log is written to the log file ,rsyslog Stop processing this message .vim /etc/rsyslog.d/haproxy.conf
___________________________________________
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.logmkdir /var/log/haproxy/
systemctl restart rsyslog.service
tail -f /var/log/haproxy/haproxy-info.log # see haproxy Access request log information for 3.1 The operation screenshot
be based on 2 The operation of
1. modify rsyslog To configure
2. establish /var/log/haproxy/ Directory and restart the service
3. Use client access web service .
4. Review the log generation again
4. Comparison of several load balancing implementations (Nginx-LVS-Haproxy)
4.1 Nginx
Nginx The advantages of :
- Working on the Internet 7 Layer above , Can target http Apply some diversion strategies , For example for domain names 、 Directory structure .Nginx Regular rules are better than HAProxy More powerful and flexible .
- Nginx The dependence on network stability is very small , Theoretically, it can ping The load function can be carried out through ,LVS It depends on the stability of the network , Stability is relatively high .
- Nginx install and configure 、 The test is simple 、 convenient , There are clear logs for investigation and management ,LVS Configuration of 、 The test will take a long time .
- Can bear high load pressure and stable , It can support tens of thousands of concurrent times , Load ratio LVS Relatively small .
- Nginx The internal fault of the server can be detected through the port , For example, according to the server processing the status code returned by the web page 、 Timeout and so on .
- Nginx It's not just a good load balancer / Reverse agent software , It's also powerful Web application server .
- Nginx As Web Reverse acceleration caching is becoming more and more mature , Faster than the traditional Squid The server is faster , It is used as a reverse proxy accelerator in many scenarios .
- Nginx As a static web page and image server , The performance in this area is excellent , At the same time, there are many third-party modules .
Nginx The shortcomings of :
- Nginx Only supported http、https and Email agreement , In this way, the scope of application is smaller .
- Health check for back-end servers , Only through the port to detect , No support for passing url To detect .
- I won't support it Session Keep it straight , Need to pass through ip_hash and cookie Guide to solve .
4.2 LVS
LVS The advantages of :
- Strong resistance to load 、 It is work in the network 4 Above the layer for distribution only , There is no flow . So the best performance in load balancing software , The memory and cpu Resource consumption is relatively low .
- LVS Stable work , Because of its strong anti load ability , It has a complete hot standby scheme .
- No flow ,LVS Distribute requests only , And traffic doesn't go out of itself , This guarantees the equalizer IO The performance of will not be affected by large traffic .
- It has a wide range of applications , because LVS Working in 4 layer , So it can do load balancing for almost all applications , Include http、 Database etc. .
LVS The shortcomings of :
- The software itself does not support regular expression processing , We can't separate the static from the dynamic . relatively speaking ,Nginx/HAProxy+Keepalived It has obvious advantages .
- If the website application is relatively large ,LVS/DR+Keepalived It's more complicated to implement . relatively speaking ,Nginx/HAProxy+Keepalived It's much simpler .
4.3 HAProxy
HAProxy The advantages of :
- HAProxy It also supports virtual hosts .
- HAProxy Support 8 Load balancing strategies .
- HAProxy The advantages of can complement Nginx Some shortcomings of , Such as support Session To keep ,Cookie The boot , At the same time, it supports obtaining the specified url To detect the state of the back-end server .
- HAProxy Follow LVS similar , It's just a load balancing software , In terms of pure efficiency HAProxy than Nginx Better load balancing speed , It is also superior in concurrent processing Nginx Of .
- HAProxy Support TCP Load balanced forwarding of protocol .
边栏推荐
- Lamp architecture that your girlfriend can read
- Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)
- 《AN4190应用笔记 天线选择指南》——天线理论2
- QT布局管理器【QVBoxLayout,QHBoxLayout,QGridLayout】
- 公司招了个五年经验的测试员,见识到了真正的测试天花板
- How can the points mall make profits
- What are the inductance parameters? How to choose inductance?
- What does websocket do?
- B. AND 0, Sum Big-Codeforces Round #716 (Div. 2)
- 酒店入住时间和离店时间的日期选择
猜你喜欢
![[go]沙盒环境下调用支付宝扫码支付](/img/d4/c6d72a697bc08f69f11121a15109b3.png)
[go]沙盒环境下调用支付宝扫码支付

Easyplayer mobile terminal plays webrtc protocol for a long time. Pressing the play page cannot close the "about us" page

The Google play academy team PK competition is in full swing!

Robot Orientation and some misunderstandings in major selection in college entrance examination

酒店入住时间和离店时间的日期选择

How important is 5g dual card dual access?

C # connection to database

网络远程访问树莓派(VNC Viewer)

Google Play Academy 组队 PK 赛,火热进行中!

Digital twin excavator of Tupu software realizes remote control
随机推荐
A number of individual stocks in Hong Kong stocks performed actively, triggering investors' speculation and concern about the recovery of the Hong Kong stock market
华为手机通过adb安装APK提示“签名不一致,该应用可能已被修改”
Online communication - the combination of machine learning and knowledge reasoning in trusted machine learning (Qing Yuan talk, issue 20, Li Bo)
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)
[go] calling Alipay to scan code for payment in a sandbox environment
Shushulang passed the listing hearing: the gross profit margin of the tablet business fell, and the profit in 2021 fell by 11% year-on-year
Hands on data analysis unit 2 section 4 data visualization
How to select securities companies? Is it safe to open a mobile account?
Tupu digital twin 3D wind farm, offshore wind power of smart wind power
以 27K 成功入职字节跳动,这份《 软件测试面试笔记》让我受益终身
千呼万唤,5G双卡双通到底有多重要?
Huawei mobile phones install APK through ADB and prompt "the signature is inconsistent. The application may have been modified."
ERP管理系统的重要性
如何选择券商?手机开户安全么?
Here comes the official zero foundation introduction jetpack compose Chinese course!
I successfully joined the company with 27K ByteDance. This interview notes on software testing has benefited me for life
How to use SQL window functions
Is your PCB ground wire right? Why should we have a master land?
股票网上开户及开户流程怎样?在线开户安全么?
电感参数有哪些?怎么选择电感?