Global_defs {icationication_email {test@sina.com} notification_email_fromadmin@test.comsmtp_server127.0.0.1smtp _ connect_timeout30router_idMYSQL_HA # identification, dual master identical} vrrp_instanceVI_1 {stateBACKUP # both sets mysql database...
Global_defs {
Notification_email {
Test@sina.com
}
Notification_email_from admin@test.com
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
Router_id MYSQL_HA # ID, the same as the dual-Master
}
Vrrp_instance VI_1 {
State BACKUP # BACKUP is set for both sets
Interface eth0
Virtual_router_id 51 # Same as Master/backup
Priority 100 # priority, 90 for backup
Advert_int 1
Nopreempt # Do not take the initiative to seize resources, only in the master priority settings, backup is not set
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.42.170
}
}
Virtual_server 192.168.42.170 3306 {
Delay_loop 2
# Lb_algo rr # LVS algorithm. if it is not used, we close it.
# Lb_kind DR # LVS mode. if this mode is not disabled, the slave server cannot connect to the master MySQL instance through VIP.
Persistence_timeout 50 # connections from the same IP address are allocated to the same real server within 60 seconds.
Protocol TCP
Real_server 192.168.42.128 3306 {# Check local mysql, backup also needs to write to check local mysql
Weight 3
Notify_down/etc/keepalived/mysql. sh # execute this script when mysq server is down to kill keepalived for failover
TCP_CHECK {
Connect_timeout 3 # connection timeout
Nb_get_retry 3 # Number of retries
Delay_before_retry 3 # retry interval
}
}
#! /Bin/sh
Killall keepalived
When mysql is stopped, keepalived cannot stop.