云计算基础服务(五)keepalived+harpoxy 中

lvs只能当做四层代理,而haproxy可以代理四层和七层,反正就是比lvs简单,通俗易懂

拷贝文件

[root@ha01 ~]# wget http://10.15.200.8/files/ha/haproxy.cfg.kafka -O /etc/haproxy/haproxy.cfg

 

 

查看文件

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon     no
defaults
    # 默认的模式{tcp|http|health}:tcp是4层 http是7层 health只会返回OK
    mode                    http
    log                     global
    option                  httplog  # 日志类别 采用httplog
    option                  dontlognull  # 不记录健康检查日志信息
    # 如果后端服务器需要获得客户端真实ip需要配置的参数, 可以从Http Header中获得客户端ip
    option forwardfor       except 127.0.0.0/8
    option http-server-close
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

listen admin_stats
        bind 0.0.0.0:8088
        mode http
        stats uri /haproxy-status
        stats auth admin:admin

listen nodex_http 0.0.0.0:80
    mode http     # http7层  tcp4四层
    balance static-rr
    option httpchk HEAD /health_check.html
    server node01_101 10.15.200.101:80 check port 80 inter 1000 rise 3 fall 3 weight 1
    server node02_102 10.15.200.102:80 check port 80 inter 1000 rise 3 fall 3 weight 1
    server node03_103 10.15.200.103:80 check port 80 inter 1000 rise 3 fall 3 weight 1
    server node03_104 10.15.200.104:80 check port 80 inter 1000 rise 3 fall 3 weight 1 backup
    # inter <delay>: 设定健康状态检查的时间间隔: 单位为毫秒  (1s=1000ms)
    # rise <count>: 定健康状态检查中, 某离线的server从离线状态转换至正常状态需要成功检查的次数
    # fall <count>: 确认server从正常状态转换为不可用状态需要检查的次数
    # weight <count>: 权重, 默认为1, 最大值为256, 0表示不参与负载均衡(不被调度)

这只是haproxy的参数,看一下就行

对主配置文件进行一个修改,修改端口号


然后再打开三台新的虚拟机,安装好httpd服务,删除默认的网页(三台都要删)

 实现haproxy服务器能够访问。(出现的内容是因为实验都是基于之前的环境做的,所以出现的example是gw主服务的域名。内容其实是可以自定义的)

 在gw服务器上面添加解析

打开一台win10虚拟机

桥接网卡,ping域名

他会自动跳,三个不同的域名

 

 

 

 

用户名为admin

密码为admin   都是默认的

 

成功!!!

我们也可以在开一台作为备份网站的存在

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值