Ubuntu 16.04 haproxy + keeplive

WEB架构

阐述各服务器用途:

   1、haproxy        实现后端Web服务器负载均衡

   2、keepalived    实现对haproxy的高可用

   3、apache static     实现静态页面的访问

   4、aoache dynamic    实现动态页面的访问

What is Keepalived ?

Keepalived is a routing software written in C. The main goal of this project is to provide simple and robust facilities(能力) for loadbalancing and high-availability to Linux system and Linux based infrastructures. Loadbalancing framework relies(依赖) on well-known and widely used Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing. On the other hand high-availability is achieved by VRRP protocol.

 

1、安装Keepalived

~# apt-get install keepalived

 

2、配置Keepalived

一个功能比较完整的keepalived 的配置文件,其配置文件keepalived.conf 可以包含三个文本块:

全局定义块

VRRP 实例定义块

虚拟服务器定义块

 

haproxy

安装配置链接

配置文件:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    pidfile /var/run/haproxy.pid
    maxconn 4000
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL). This list is from:
    #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
    ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
    ssl-default-bind-options no-sslv3

defaults
    log    global
    mode    http
    option    httplog
    option    dontlognull
    option  http-server-close
    option  forwardfor except 127.0.0.0/8
    maxconn 60000
    retries 3
        timeout connect 10s
        timeout client  1m
        timeout server  1m
    timeout check  10s
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

listen stats
    bind 0.0.0.0:1080
    stats refresh 30s
    stats uri /stats
    stats realm Haproxy Manager
    stats auth admin:admin
    
frontend main
    bind 0.0.0.0:80
    
    acl url_static path_beg -i /static /images /javascript /stylesheets
    acl url_static path_end -i .jpg .gif .png .css .js
    acl url_dynamic path_end -i .jsp
    use_backend static if url_static
    use_backend dynamic if url_dynamic
    default_backend static


backend static
    balance roundrobin
    server websrv1 192.168.20.178:80 check maxconn 1000
    server websrv2 192.168.20.179:80 check maxconn 1000

backend dynamic
    balance roundrobin
    server dynamic1 192.168.20.177:8080 inter 3000 rise 2 fall 3 check maxconn 100
    server dynamic2 192.168.20.181:8080 inter 3000 rise 3 fall 3 check maxconn 100

 

转载于:https://www.cnblogs.com/vincenshen/p/6417992.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值