dopost 发表于 2018-12-31 08:27:54

在CentOS 7.0上安装keepalived,实现Nginx主备

  1、安装目录包
yum install -y net-tools psmisc  2、安装keepalived
yum install -y ipvsadm keepalived  3、master配置文件
! Configuration File for 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
}
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 {
   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
}
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.运维网.com/468033/1676442



页: [1]
查看完整版本: 在CentOS 7.0上安装keepalived,实现Nginx主备