docker - haproxy 没有对 docker swarm 中的测试应用程序进行负载平衡
问题描述
我有 3 个虚拟机(虚拟机)。所有这些都设置为使用带有 keepalived 的单个 VIP。(192.168.100.200)。我在每个 vm 上有一个代理,在每个 vm 上有一个测试应用程序。(我正在测试一个高可用性场景,其中丢失一个或两个节点,让设置继续进行)。我让keepalived正常工作。只是请求没有负载平衡,它总是去同一个实例。
出了什么问题?
version: "3.8"
services:
# HAproxy
haproxy :
image : haproxy:2.3.2
container_name : haproxy
networks :
- app-net
ports :
- 80:80
volumes :
- /etc/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
deploy :
mode : global
restart_policy :
condition : on-failure
delay : 5s
max_attempts : 3
window : 120s
# Nginx test site
wwwsite :
image : nginxdemos/hello
networks :
- app-net
ports :
- 8080:80
deploy :
mode : global
networks :
app-net :
driver : overlay
name : app-net
attachable: true
haproxy.conf
global
stats socket /var/run/haproxy.stat mode 660 level admin
stats timeout 30s
user root
group root
resolvers docker
nameserver dns1 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold other 10s
hold refused 10s
hold nx 10s
hold timeout 10s
hold valid 10s
hold obsolete 10s
defaults
timeout connect 10s
timeout client 30s
timeout server 30s
mode http
frontend fe_web
mode http
bind *:80
default_backend nodes
backend nodes
balance roundrobin
server node1 192.168.100.201:8080 check
server node2 192.168.100.202:8080 check
server node3 192.168.100.203:8080 check
listen stats
bind *:8081
mode http
stats enable
stats uri /
stats hide-version
解决方案
推荐阅读
- kotlin - kotlin中接口引用如何访问类方法和变量
- java - 如何打开现有的 android 应用程序并使用颤振向其发送数据
- postgresql - Postgres 在 Schema 中使用 Hstore 给出运算符不存在的错误
- maven - 在“更新 Maven 项目”期间发生内部错误。java.lang.ExceptionInInitializerError
- sql-server - Oracle 和 SQL Server `CEIL/CEILING` 函数返回不同的结果
- python - Matplotlib 返回:AttributeError:'property' 对象没有属性'__name__'
- html - 如何设置比下拉宽度长的下拉项的宽度
- shiny - 有没有办法在闪亮的仪表板上制作布告栏?
- daxstudio - 如何在 Daxstudio 中更改数据库
- css - 在 Docker 容器中编辑 AWX CSS