keepalived做双机热备

安装keepalived
tar zxvf keepalived-1.1.19.tar.gz
cd keepalived-1.1.19
./configure --prefix=/usr/local/keepalived
make
make install
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
mkdir /etc/keepalived
cd /etc/keepalived/
#####################################################
! Configuration File for keepalived
global_defs {
   notification_email {
   yeli4017@163.com
        }
   notification_email_from yeli4017@163.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id web_nginx
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    garp_master_delay 10
    smtp_alert
    virtual_router_id 51
    mcast_src_ip 172.16.3.51  
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111chtopnet
    }
    virtual_ipaddress {
        172.16.3.199
    }
}
辅助服务器
! Configuration File for keepalived
global_defs {
   notification_email {
   yuhongchun027@163.com
        }
   notification_email_from keepalived@chtopnet.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    mcast_src_ip 172.16.3.51              <==主nginx的IP的地址
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass chtopnet
    }
    virtual_ipaddress {
        172.16.3.199
    }
}
 

你可能感兴趣的:(职场,休闲,双机热备)