当前位置:网站首页>【集群】haproxy负载均衡
【集群】haproxy负载均衡
2022-06-11 07:29:00 【雪碧不要气】
前言
本博客内容仅为记录博主思路,仅供参考,一切以自己实践结果为准。
一、haproxy负载均衡
1.0 架构概况
| 作用 | IP地址 | 安装服务 |
|---|---|---|
| 主负载均衡器 | 192.168.13.10 | haproxy-1.5.19 |
| 节点服务器1 | 192.168.13.20 | httpd |
| 节点服务器2 | 192.168.13.30 | httpd |
| 日志收集器 | 192.168.13.40 | ipvsadm/keepalived |
1.1 负载均衡调度器
systemctl stop firewalld
setenforce 0
yum install -y pcre-devel bzip2-devel gcc gcc-c++ make
上传压缩包
tar zxvf haproxy-1.5.19.tar.gz
cd haproxy-1.5.19/
make TARGET=linux2628 ARCH=x86_64
make install
mkdir /etc/haproxy
cp examples/haproxy.cfg /etc/haproxy/
vim /etc/haproxy/haproxy.cfg
4行:log /dev/log local0
5行:log /dev/log local1 notice
8行:#chroot /usr/share/haproxy
26行以下:全部删除
26-30行:添加节点服务器信息
listen webcluster 0.0.0.0:80
option httpchk GET /index.html
balance roundrobin
server inst1 192.168.13.20:80 check inter 2000 fall 3
server inst1 192.168.13.30:80 check inter 2000 fall 3
cp /opt/haproxy-1.5.19/examples/haproxy.init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
service haproxy start
1.2 节点服务器
systemctl stop firewalld
setenforce 0
yum install httpd -y
echo 'this is web1!' >/var/www/html/index.html
systemctl start httpd
另一台服务器重复操作
二、结语
- 心态要稳,错了慢慢排
- 配置文件中的option httpchk GET /index.html这一行,对应着节点服务器最后默认的文件类型,必须对应上,否则返回503
边栏推荐
- Compound ratemodel contract analysis
- Crmeb/v4.4 Standard Version open version mall source code applet official account h5+app mall source code
- Gobang interface of mobile console (C language)
- Arduino_ Esp32 development record
- 【IoT】智能硬件:如何获取硬件产品的wifi信号强度
- QT interface nested movement based on qscrollarea
- [STL source code analysis] summary notes (9): set/multiset and map/multimap
- Raspberry pie builds a full-featured NAS server (07): manage your library & read as you please
- 2020080 simulation competition [horizontal and vertical coordinates do not affect each other, cactus minimum cut, combined meaning translation formula]
- [STL source code analysis] summary notes (1): Opening
猜你喜欢

多线程复习总结之解析Volatile关键字
![[analysis of STL source code] summary note (4): behind the scenes hero allocator](/img/b9/cf53fd8f933042ff65844d61eca55e.jpg)
[analysis of STL source code] summary note (4): behind the scenes hero allocator
![[STL source code analysis] summary notes (12): functors and adapters](/img/6d/a3a9cde2c8792579af7505c2226914.jpg)
[STL source code analysis] summary notes (12): functors and adapters

Building a full-featured NAS server with raspberry pie (06): built-in file synchronization tool for penetration

If you want to save an IP address, what data type is better? 99% of people will answer wrong!

Sdl-2 thread logic

Gobang interface of mobile console (C language)

Decimal to binary

Classification of MNIST datasets with keras

测试4年裸辞失业,面试15k的测试岗被按在地上摩擦,结局让我崩溃大哭...
随机推荐
R语言并行计算实战教程
Classification of MNIST datasets with keras
自动化测试的生命周期是什么?
Decimal to binary
I/o multiplexing - select/poll/epoll
Mistakes in Niuke JS exercise
Paper size and book size
Wc2020 course selection
【CF#262 (Div. 2)】 A. Vasya and Socks
Regular Expression Matching
【AtCoder2387】+/- Rectangle
【AtCoder2376】Black and White Tree(博弈)
【集群】LVS+keepalived高可用集群
P3172 [cqoi2015] data selection (Mobius inversion + Du Jiao sieve)
Seata的几种事务模式
20200727 T2 small w playing game [generating function (binomial inversion technique)]
MFC auxiliary CString string splicing
C language volatile
Sdl-3 YUV playback
Qstring to hexadecimal qstring