keepalived管理LVSDR模式

keepalived管理LVSDR模式

   张吉吉     2020年7月29日 02:46     1538    

1、全局配置

global_defs {

   notification_email {

        admin@example.com

   }

   notification_email_from admin@example.com

smtp_server 127.0.0.1

stmp_connect_timeout 30

   router_id LVS_157

}

notification_email

keepalived在发生诸如切换操作时需要发送email通知,以及email发送给哪些邮件地址,邮件地址可以多个,每行一个

notification_email_from

表示发送通知邮件时邮件源地址

smtp_server 127.0.0.1

发送email时使用的smtp服务器地址

smtp_connect_timeout 30

连接smtp连接超时时间

router_id LVS_157

机器标识,标识唯一

 

2、实例配置

vrrp_instance VI_1 {

    state MASTER|SLAVE

    interface ens33

    virtual_router_id 51

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.60.100/32 brd 192.168.60.100 dev ens33 label ens33:0

    }

}

vrrp_instance

实例定义,后边名称可以任意定义

state

指定 keepalived 的角色,必须大写 可选值:MASTER|BACKUP

interface

网卡设置,填写对应网卡名称

virtual_router_id

虚拟路由标识,同一个vrrp 实例使用唯一的标识,MASTER和BACKUP 的 同一个 vrrp_instance 下 这个标识必须保持一致

priority

优先级,数字越大,优先级越高

advert_int  

设定 MASTER 与 BACKUP 负载均衡之间同步检查的时间间隔,单位为秒,两个节点设置必须一样

authentication

验证类型和密码

virtual_ipaddress

虚拟IP地址,可以配置多个

track_script

配置vrrp_script定义的名称,这里就是nginx_check

 

3、LVS DR模式配置

virtual_server 192.168.60.100 80 {

    delay_loop 6

    lb_algo rr

    lb_kind DR

    persistence_timeout 0

    protocol TCP

    real_server 192.168.60.154 80 {

        weight 1

        TCP_CHECK{

                connect_timeout 10

                nb_get_retry 3

                delay_before_retry 3

                connect_port 80

        }

    }

real_server 192.168.60.155 80 {

        weight 1

        TCP_CHECK{

                connect_timeout 10

                nb_get_retry 3

                delay_before_retry 3

                connect_port 80

        }

    }

 

    real_server 192.168.60.156 80 {

        weight 1

        TCP_CHECK{

                connect_timeout 10

                nb_get_retry 3

                delay_before_retry 3

                connect_port 80

        }

    }

}

virtual_server

配置虚拟IP

delay_loop

健康检查的时间间隔

lb_algo rr|wrr|lc|wlc|lblc|sh|dh

LVS调度算法

lb_kind DR|NAT|TUN

LVS的模式

persistence_timeout

持久化超时时间  

protocol TCP

协议

real_server

配置真实IP

weight

主机权重值

TCP_CHECK

健康检查标志

connect_timeout

链接超时时间

nb_get_retry

get尝试次数

delay_before_retry

尝试之前延迟多长时间

connect_port

链接端口

 


文章评论

0

其他文章