码迷,mamicode.com
首页 > 系统相关 > 详细

#Linux Keepalived 负载均衡

时间:2017-10-27 17:44:56      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:val   ignore   ati   host   配置   rip   live   min   enc   

##

系统环境配置

#!/bin/bash
case $1 in
        start)
                echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
                echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
                echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
                echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
;;
        stop)
                echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
                echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore
                echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
                echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce
;;
esac

环回口配置ip

ifconfig lo:1 192.168.1.189 netmask 255.255.255.255 up

 

##

配置文件

! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server localhost
   smtp_connect_timeout 30
   router_id master
}

vrrp_script chk_nginx_port {
    script "killall -0 httpd >/dev/null 2>&1"
    interval 1
    weight -2
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 53
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.189/32
    }
    track_script {
        chk_nginx_port
    }
}

virtual_server 192.168.1.189 80 {
    delay_loop 6
    lb_algo wrr
    lb_kind DR
    nat_mask 255.255.255.0
#    persistence_timeout 50
    protocol TCP

    real_server 192.168.1.161 80 {
        weight 1
        TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
                connect_port 80
                }
    }

    real_server 192.168.1.185 80 {
        weight 2
        TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
                connect_port 80
                }
        }
}

##

#Linux Keepalived 负载均衡

标签:val   ignore   ati   host   配置   rip   live   min   enc   

原文地址:http://www.cnblogs.com/lwsup/p/7743963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!