CentOS 7.0 安装keepalived

1、安装目录包

yum install -y net-tools psmisc

2、安装keepalived

yum install -y ipvsadm keepalived

3、master配置文件

! Configuration File for keepalived
global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_script chk_nginx {
   script "killall -0 nginx"
   interval 1
   weight -15
}
vrrp_instance VI_1 {
    state MASTER
    interface eno16777736
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.1.10
    }
    track_script {
        chk_nginx
        }
}

4、backup配置文件

! Configuration File for keepalived
global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}
vrrp_script chk_nginx {
   script "killall -0 nginx"
   interval 1
   weight -15
}
vrrp_instance VI_1 {
    state BACKUP
    interface eno16777736
    virtual_router_id 51
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        172.16.1.10
    }
    track_script {
        chk_nginx
        }
}

5、设置开启启动和启动keepalived

systemctl enable keepalived
systemctl start keepalived

参考博文:http://soulful.blog.51cto.com/468033/1676442

你可能感兴趣的:(keepalived)