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