[转]Centos6.5安装配置keepalived

参考博文:

Centos6.5安装配置keepalived

CentOS6.5 keepalived详解及实现Nginx服务的高可用性

CentOS6.5 LVS + KeepAlived搭建步骤 

我采用yum 方式  直接安装  版本为1.2.13

#  yum -y install keepalived
global_defs {                  #全局定义 
   notification_email {       #定义邮件提醒  一行一个 多个人写多行
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc    #以什么人的身份发邮件,发件人
   smtp_server 192.168.200.1                                #指定发邮件的服务器
   smtp_connect_timeout 30                                  #连接邮件服务器超时时长
   router_id LVS_DEVEL                                      #路由ID
}

vrrp_instance VI_1 {                                        
    state MASTER                                            #备份服务器上将MASTER改为 BACKUP
    interface eth0                                          #HA 检测网络接口
    virtual_router_id 51                                    #主、备机的 virtual_router_id 必须相同
    priority 100                                            # 主、备机取不同的优先级,主机值较大,备份机值较小
    advert_int 1                                            VRRP Multicast 广播周期秒数
    authentication {
        auth_type PASS                                      #VRRP 认证方式
        auth_pass 1111                                      #VRRP 口令字
    }
    virtual_ipaddress {                                     VRRP HA 虚拟地址 如果有多个VIP,继续换行填写
        192.168.200.16
        192.168.200.17
        192.168.200.18
    }
}

virtual_server 192.168.200.100 443 {
    delay_loop 6                         # 每隔 6 秒查询 realserver 状态
    lb_algo rr                           #lvs 算法
    lb_kind DR                          Direct Route  
    nat_mask 255.255.255.0
    persistence_timeout 50              # 同一IP 的连接50 秒内被分配到同一台realserver
    protocol TCP                        # 用 TCP 协议检查 realserver 状态

    real_server 192.168.201.100 443 {
        weight 1                          #(权重)
        SSL_GET {
            url {
              path /
              digest ff20ad2481f97b1754ef3e12ecd3a9cc
            }
            url {
              path /mrtg/
              digest 9b3a0c85a887a256d6939da88aabd8cd
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

virtual_server 10.10.10.2 1358 {
    delay_loop 6
    lb_algo rr 
    lb_kind NAT
    persistence_timeout 50
    protocol TCP

    sorry_server 192.168.200.200 1358

    real_server 192.168.200.2 1358 {
        weight 1
        HTTP_GET {
            url { 
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url { 
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url { 
              path /testurl3/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }

    real_server 192.168.200.3 1358 {
        weight 1
        HTTP_GET {
            url { 
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334c
            }
            url { 
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334c
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

virtual_server 10.10.10.3 1358 {
    delay_loop 3
    lb_algo rr 
    lb_kind NAT
    nat_mask 255.255.255.0
    persistence_timeout 50
    protocol TCP

    real_server 192.168.200.4 1358 {
        weight 1
        HTTP_GET {
            url { 
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url { 
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url { 
              path /testurl3/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }

    real_server 192.168.200.5 1358 {
        weight 1
        HTTP_GET {
            url { 
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url { 
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url { 
              path /testurl3/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
原文地址:https://www.cnblogs.com/wuling129/p/4864385.html