LVS+keepalived配置

一、系统环境准备:

1、keepalive主服务器

主机名称:dir

系统环境:CentOS release 6.5 (Final)

外网ip:192.168.1.203(网络模式桥接)

vip:192.168.1.250/32(网络模式eht0)

# echo 1 > /proc/sys/net/ipv4/ip_forward

2、realserver1服务器

主机名:rs1

系统环境:CentOS release 6.5 (Final)

外网ip:192.168.1.201(网络模式桥接)

安装nginx:默认页面访问是web1

3、realserver2服务器和keepalived备用服务器在同一台机器

主机名:rs2

系统环境:CentOS release 6.5 (Final)

外网ip:192.168.1.202(网络模式桥接)

安装nginx:默认页面访问是web2

二、keepalive服务器配置

# yum -y install keepalived

# vim /etc/keepalived/keepalived.conf

vrrp_instance VI_1 {

    state MASTER   #BACKUP

    interface eth0

    virtual_router_id 51

    priority 100  #90

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.250

    }

}

virtual_server 192.168.1.250 80 {

    delay_loop 6

    lb_algo rr

    lb_kind DR

    persistence_timeout 0

    protocol TCP

    real_server 192.168.1.201 80 {

        weight 100

        TCP_CHECK {

            onnect_timeout 10

            nb_get_retry 3

            delay_before_retry 3

       connect_port 80

        }

    }

    real_server 192.168.1.202 80 {

        weight 100

        TCP_CHECK {

            onnect_timeout 10

            nb_get_retry 3

            delay_before_retry 3

            connect_port 80

        }

    }

}

# /etc/init.d/keepalived start

posted @ 2016-04-15 09:12  fansik  阅读(273)  评论(0编辑  收藏  举报