LVS+keepalived配置

Posted 专注it

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

以上是关于LVS+keepalived配置的主要内容,如果未能解决你的问题,请参考以下文章

LVS-DR+Keepalived+httpd(双主)

LVS+Keepalived高可用群集

Lvs+keepalived+mysql(主主复制)

lvs+keepalived实现负载均衡

LVS+Keepalived

keepalived+lvs+tomcat+nfs架构部署