8.14 haproxy负载均衡+mysql读写分离

haproxy负载均衡

[root@haproxy01 ~]# yum -y install ntpdate

[root@haproxy01 ~]# yum -y install ntp

[root@haproxy01 ~]# systemctl start ntpd

安装haproxy

[root@haproxy01 ~]# yum -y install ntpdate

配置文件的地址

[root@haproxy01 ~]# rpm -ql haproxy

[root@haproxy01 ~]# vim /etc/haproxy/haproxy.cfg

 frontend  main *:80                        //修改63行为80

#    use_backend static          if url_static   //注释掉这一行

default_backend             web            //修改68行为web

  backend web                              //在最后添加这几行

       balance    roundrobin

       server weba  192.168.2.200:80 check

       server webb  192.168.2.201:80 check

[root@haproxy01 ~]# systemctl start haproxy

[root@haproxy01 ~]# systemctl enable haproxy.service

访问haproxy自己,对web01,web02实现了轮询负载均衡

[root@haproxy01 ~]# curl 192.168.2.11

web---------01

[root@haproxy01 ~]# curl 192.168.2.11

web----------02

[root@haproxy01 ~]# vim /etc/haproxy/haproxy.cfg

# 定义web管理界面

listen statistics

       bind *:9090   #定义监听端口

       mode http    #默认使用协议

       stats enable   #启用stats

       stats uri /hadmin?stats   #自定义统计页面的url

       stats auth admin:admin   #统计页面的账号密码

       stats hide-version        #隐藏在统计页面上的

       stats refresh 30s        #统计页面自动刷新时间

       stats admin if TRUE      #如果认证通过就做管理

       stats realm hapadm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值