做网站的注意点,免费网页app一键生成软件,电商行业建设网站,广州有做网站的公司吗haproxy的原理: 提供高可用、负载均衡以及基于TCP(四层)和HTTP(七层)应用的代理,支持虚拟主机,开源可靠的一款软件。 适用于哪些负载特别大的web站点,这些站点通常又需要回话保持和七…- haproxy的原理: 
- 提供高可用、负载均衡以及基于TCP(四层)和HTTP(七层)应用的代理,支持虚拟主机,开源可靠的一款软件。
 
 - 适用于哪些负载特别大的web站点,这些站点通常又需要回话保持和七层处理。
 
 - haproxy运行在时下的硬件上,完全可以支持数以万计的并发连接。
 
 - haproxy的特性: 
- 可靠和稳定性非常好,可以与硬件级的F5负载均衡设备相互媲美
 
   - 支持客户端的keepalived功能,减少客户端与haproxy的多次三次握手导致资源量费,让多个请求在一个tcp连接中完成。
 
   - 配置文件: 
- haproxy.cfg主要有两部分组成:global和proxies配置段 
- global:全局配置 
- 进程及安全配置相关的参数、性能调整相关的参数、Debug参数
 
 
 - proxies:代理配置段 
- defaults:为为frontend, backend, listen提供默认配置
 
 - fronted:前段,相当于nginx,server{}
 
 - backend:后端,相当于nginx,upstream{}
 
 - listen:同时拥有前段和后端,适用于一对一环境
 
 
 
 - 本章实验配置:   
- 网站节点2:192.168.8.10 
- 1.配置调度器:   
- vim /etc/haproxy/haproxy.cfg 
- #定位63行 frontend main *:80 (将后面端口修改为80)
 
 - 修改backend字段:  
- server real_server1 192.168.8.9:80 check inter 10000 rise 1 fall 3 weight 1
 
 - server real_server2 192.168.8.10:80 check inter 10000 rise 1 fall 3 weight 1
 
 - 配置解释: 
- balance (roundrobin):轮询算法
 
 - check inter 1000:每隔1000毫秒检测一次
 
    
 
 
 - 启动服务:systemctl start haproxy
 
 
 - 2.分别在8.9和8.10服务器上安装nginx,修改网页,测试轮询 
- web1:  
- echo "web1" > /usr/share/nginx/html/index.html
 
  
 - web2:  
- echo "web2" > /usr/share/nginx/html/index.html
 
  
 
  - 4.添加监控页面配置在haproxy.cfg配置文件中: 
- vim /etc/haproxy/haproxy.cfg 
- 添加在最下方即可:      
- stats realm welcome login\ Haproxy
 
 - stats auth admin:admin123
 
  
 - 重启服务:systemctl restart haproxy
 
 
 - 通过访问网页方式,查看监控页面 
- http://192.168.8.8:11001/admin  
 
  
 
 - 5.配置haproxy session会话保持: 
- vim /etc/haproxy/haproxy.cfg 
- 修改backend 字段更换为:       
- option httpchk GET /index.html
 
 - server app1 192.168.8.9:80 cookie server1 check
 
 - server app2 192.168.8.10:80 cookie server2 check