haproxy负载

haproxy负载
第一台
yum –y install haproxy.x86_64
mv haproxy.cfg haproxy.cfg.back
vim haproxy.cfg
global
log 127.0.0.1 local2 info
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 455350
user haproxy
group haproxy
daemon
defaults
mode http
log global
option httplog
timeout connect 10s
timeout client 30s
timeout server 30s
frontend http-in
bind *:80
default_backend backend_servers
option forwardfor
option httpclose
backend backend_servers
balance roundrobin
server web1 192.168.126.141:80 cookie 1 check inter 5000 fall 3 rise 2 weight 1
#改成web1的IP地址
server web2 192.168.126.137:80 cookie 2 check inter 5000 fall 3 rise 2 weight 1
#改成web2的IP地址
listen stats
mode http
bind *:10000 #进入监控页面的端口号
stats enable
stats uri /haproxy
stats realm HAProxy\ Statistics
stats auth admin:123.com #进入监控页面的账号和密码
systemctl restart haproxy.service #重新启动haproxy
第二台
yum –y install nginx
vim /etc/nginx/nginx.conf
42:root /html #任意路径
43:index index.html index.htm index.php default.jsp; #编写访问页面类型
mkdir /html #创建42行所写的文件
vim /html/index.html #在创建的文件中编写测试页面
1111111
chown nginx:nginx /html/ -Rf #赋权
sysytemctl restart nginx.service #重启nginx
第三台
yum –y install nginx
vim /etc/nginx/nginx.conf
42:root /html #任意路径
43:index index.html index.htm index.php default.jsp; #编写访问页面类型
mkdir /html #创建42行所写的文件
vim /html/index.html #在创建的文件中编写测试页面
22222222
chown nginx:nginx /html/ -Rf #赋权
sysytemctl restart nginx.service #重启nginx
测试
在浏览器输入第一台的IP地址发现页面自由转换为web1和web2的测试页面为成功
在浏览器输入第一台的IP地址加上:10000/haproxy进入监控页面用户名admin密码123.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

君夜-专注搞技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值