负载均衡的比例(权重,ip_hash,轮询)

一:负载均衡的比例

1.轮询
copy
# 默认情况下,Nginx负载均衡的轮询状态。 upstream supermarie { server 172.16.1.7:80; server 172.16.1.8:80; server 172.16.1.9:80; }
2.权重
copy
Nginx中的权重0-100,数字越大,权重越高。 upstream supermarie { server 172.16.1.7:80 weight=9; server 172.16.1.8:80 weight=5; server 172.16.1.9:80 weight=1; }
3.ip_hash
copy
# 每一个IP固定访问某一个后端。 upstream supermarie { server 172.16.1.7:80; server 172.16.1.8:80; server 172.16.1.9:80; ip_hash; }

二:测试轮询

copy
web服务器测试 web02 与 web03 轮流追加 /opt/Mario [root@web01 Mario]# echo web01 > web.html

image

1.测试
copy
nginx -t
2.重启
copy
systemctl restart nginx
3.网址测试
copy
www.game.com/web.html

image

三:测试ip_hash

copy
本机测试(每ip固定访问某一个后端) curl http://192.168.15.5/web.html
posted @   AlexEvans  阅读(487)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
🚀