环境准备:

两台节点部署keepalived,并且设为互为主从,实现高可用。

两台从节点部署nginx以及相关组件,作为真实服务器实现动态网站上线。

 

一、MASTER(BACKUP)节点下载keepalived并且配置文件。

作为

1)  yum -y install keepalived

设置为v1的主节点,v2的从节点

虚拟ip为192.168.253.250

后端真实服务器ip为 192.168.253.146  和  192.168.253.188

[root@localhost ~]# cat /etc/keepalived/keepalived.conf 
! 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_skip_check_adv_addr
#   vrrp_strict
#   vrrp_garp_interval 0
#   vrrp_gna_interval 0
}

vrrp_instance VI_1 {
    state MASTER
    interface ens33
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.253.250
    }
}
vrrp_instance VI_2 {
    state BACKUP
    interface ens33
    virtual_router_id 52
    priority 99
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 2222
    }   
    virtual_ipaddress {
        192.168.253.200
    }   
}   

virtual_server 192.168.253.250 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP

    real_server 192.168.253.188 80 {
        weight 1
        HTTP_GET {
            url {
              path /
          state_code 200
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

virtual_server 192.168.253.250 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP

    real_server 192.168.253.146 80 {
        weight 1
        HTTP_GET {
            url {
              path /
              state_code 200
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
cat /etc/keepalived/keealived.conf

相关文章:

  • 2021-10-21
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-12-18
  • 2021-09-17
  • 2022-01-05
猜你喜欢
  • 2021-06-10
  • 2022-12-23
  • 2022-12-23
  • 2021-04-21
  • 2021-05-27
  • 2022-12-23
  • 2021-10-03
相关资源
相似解决方案