内容简介:HAproxy簡單配置
用途: TCP/HTTP反向代理,四层负载均衡,适合高可用环境。 Linux6.4版本后haproxy已随base仓库收录进来。
主程序:/usr/sbin/haproxy
主配置文件:/etc/haproxy/haproxy.cfg
启动文件:/usr/lib/systemd/system/haproxy.service
安装:yum -y install haproxy调度器实现一个负载均衡,两台客户端安装httpd/nginx和mariadb/mysql(实验环境注意关闭iptables/firewalld和selinux),并建议时间全部同步(chrony服务或直接ntpdate 172.18.0.1/172.16.0.1)
配置haproxy配置文件,vim /etc/haproxy/haproxy.cfg (配置之前好习惯把配置文件备份),定义frontend前端和backend后端两个字段
frontend myweb *:80 (frontend后名字要唯一,绑定的地址和要监听的端口)
default_backend realserver
backend realserver (backend后端服务器名字也要唯一,并要和上面 default_backend定义相同 )
balance roundrobin (调度算法,默认轮询)
server web1 172.18.250.238:80 check (负载均衡web1,健康检查)
server web2 172.18.251.93:80 check (负载均衡web2,健康检查)
随后启动haproxy服务,可用ss -tnlp查看80端口是否监听,然后访问调度器IP测试轮询后台web页面效果。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 6、如何获取配置中心的配置
- React降级配置及Ant Design配置
- vscode 配置eslint 开发vue的相关配置
- git commit 规范校验配置和版本发布配置
- hadoop地址配置、内存配置、守护进程设置、环境设置
- 在hibernate中配置事务级别与命名查询配置【原创】
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Nature of Code
Daniel Shiffman / The Nature of Code / 2012-12-13 / GBP 19.95
How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital w......一起来看看 《The Nature of Code》 这本书的介绍吧!