Keepalived双机热备实现故障时发送邮件通知

目前项目已经采用nginx来实现负载均衡,但是nginx调度器只有一台,上次还意外的down机一次,导致整个服务应用全部瘫痪,这次准备再加一个调度器来实现站点高可用性,也就是常说的双机热备了。

master: 192.168.1.241
 backup: 192.168.1.242
 漂移IP:192.168.1.243

1,主备调度器都安装keepalived软件
 安装过程如下:
 ./configure --prefix=/usr/local/keepalived && make && make install
 cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
 cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
 mkdir /etc/keepalived
 cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
 cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
 service keepalived start
 可以先用命令 service keepalived start 启动进行测试,看进程能够启动,注意查看log.
 2,主调度器配置如下:
 ! Configuration File for keepalived
 global_defs {
    router_id LVS_DEVEL
 }
 vrrp_sync_group VG_1 {
    group {
        VI_1
    }
    notify_master /etc/keepalived/sendmail.pl
 }
 vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.243
    }
 }

CentOS 6.3下Haproxy+Keepalived+Apache配置笔记

Haproxy + KeepAlived 实现WEB群集 on CentOS 6

Keepalived+Haproxy配置高可用负载均衡

Haproxy+Keepalived构建高可用负载均衡

2,备调度器配置如下:
 ! Configuration File for keepalived
 global_defs {
    router_id LVS_DEVEL
 }
 vrrp_sync_group VG_1 {
    group {
    VI_1
    }
    notify_master /etc/keepalived/sendmail.pl
 }
 vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.243
    }
 }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/35350f2e39179f955101bd372c16a051.html