haproxy keepalived

haproxy.cfg

 

# This is a test configuration.
# It requires another server running on local port 9000, preferably httpterm
# with the file 'httpterm-basic.cfg' from the same directory.
#
# It will wait for HTTP connections on port 8000 and TCP connections on port
# 8001. It will load-balance them across active servers, and will be able to
# validate queuing. Stats are available at URI /?stats.

global
        maxconn 4096
        user haproxy
        group haproxy
        daemon

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option  redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen  webcluster *:80
        mode    http
        stats   enable
        stats   auth us3r:passw0rd
        balance roundrobin
        option httpchk HEAD / HTTP/1.0
        option forwardfor
        cookie LSW_WEB insert
        option httpclose
        server  srv1 192.168.0.183:7003 cookie s1 check
        server  srv2 192.168.0.183:7006 cookie s2 check
    server  srv3 192.168.0.197:7004 cookie s2 check

keepalived.conf

 

    notification_email {
        your@emailaddress.com     # Email address for notifications
    }
    notification_email_from loadb01@domain.ext  # The from address for the notifications
    smtp_server 127.0.0.1     # You can specifiy your own smtp server here
    smtp_connect_timeout 15
}
 
# Define the script used to check if haproxy is still working
vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 2
    weight 2
}
 
# Configuation for the virtual interface
vrrp_instance VI_1 {
    interface eth0
    state BACKUP        # set this to BACKUP on the other machine
    priority 100        # set this to 100 on the other machine
    virtual_router_id 51
 
    smtp_alert          # Activate email notifications
 
    authentication {
        auth_type AH
        auth_pass myPassw0rd      # Set this to some secret phrase
    }
 
    # The virtual ip address shared between the two loadbalancers
    virtual_ipaddress {
        192.168.0.200
    }
    
    # Use the script above to check if we should fail over
    track_script {
        chk_haproxy
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值