Keepalive01:
! Configuration File for keepalived global_defs { notification_email { ##接收邮件的地址;就是说通知邮件应该发送给谁,通常写自己的地址 root@localhost ##收件人,表示发送给本机的root用户 } notification_email_from keepalived@localhost ##发件人 smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS #标识本节点的字条串,通常为hostname,但不一定非得是hostname。故障发生时,邮件通知会用到。 vrrp_mcast_group4 224.0.100.19 ##vrrp协议是通过多播向外发送的;这里指的是ipv4的多播地址 } vrrp_instance VI_1 { #自定义名称:VI_1 state BACKUP interface ens192 virtual_router_id 51 #主备ID相同 priority 100 ##优先级 nopreempt ##工作于非抢占模式 advert_int 1 ##广播通告的时间间隔,每隔多长时间向外发送自身的心跳信息,默认是一秒钟一次 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 172.18.117.194 dev ens192 } } virtual_server 172.18.117.194 80 { # 定义转移ip端口80的集群服务 delay_loop 3 lb_algo rr lb_kind DR protocol TCP sorry_server 127.0.0.1 80 real_server 172.18.117.192 80 { # 定义集群服务包含的RS 1 weight 1 # 权重为1 HTTP_GET { # 定义RS1的健康状态检测 url { path / status_code 200 } connect_timeout 1 nb_get_retry 3 delay_before_retry 1 } } real_server 172.18.117.193 80 { # 定义集群服务包含的RS 2 weight 1 # 权重为1 HTTP_GET { # 定义RS2的健康状态检测 url { path / status_code 200 } connect_timeout 1 nb_get_retry 3 delay_before_retry 1 } } }
Keepalive02:
! Configuration File for keepalived global_defs { notification_email { root@localhost } notification_email_from keepalived@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS vrrp_mcast_group4 224.0.100.19 } vrrp_instance VI_1 { state BACKUP interface ens192 virtual_router_id 51 priority 99 nopreempt advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 172.18.117.194 dev ens192 } } virtual_server 172.18.117.194 80 { # 定义转移ip端口80的集群服务 delay_loop 3 lb_algo rr lb_kind DR protocol TCP sorry_server 127.0.0.1 80 real_server 172.18.117.192 80 { # 定义集群服务包含的RS 1 weight 1 # 权重为1 HTTP_GET { # 定义RS1的健康状态检测 url { path / status_code 200 } connect_timeout 1 nb_get_retry 3 delay_before_retry 1 } } real_server 172.18.117.193 80 { # 定义集群服务包含的RS 2 weight 1 # 权重为1 HTTP_GET { # 定义RS2的健康状态检测 url { path / status_code 200 } connect_timeout 1 nb_get_retry 3 delay_before_retry 1 } } }