Environment:
Os:centos 7_x64
Database: mysql-5.7
master:192.168.119.23
backup:192.168.119.24
vip:192.168.119.138
Keepalived+mysql the detailed configuration of the construction process is not described, many of the online configuration documents written in detail can refer to, we go straight to the topic.
Here is the main share in the construction of the company's Keepavlied+mysql appeared a very strange phenomenon, when a server for Master Master Shibangding VIP 192.168.119.138, on a native can ping 192.168.119.138 and Telnet 192.168.119.138 Port 3306, and Ping 192.168.119.138 on the B server is OK, but the routing error is not found when Telnet 192.168.119.138 3306. Also check B server at this time there is no VIP is normal phenomenon, but Telnet vip+ other ports are normal.
Frequently repeated tests have found that when a and B servers run keepalived concurrently, the server that is the backup role cannot telnet to 192.168.119.138 3306, and when the keepalived on the backup role server is turned off, However, you can ping telnet normally.
The problem is still in the configuration file, the LVs of the keepalived.conf configuration file will not be used to debug the algorithm Lb_algo and forwarding mode lb_kind removed , It is these two items that cause the backup server to be unable to access MySQL. The normal configuration file is as follows:
[Email protected] ~]# vi/etc/keepalived/keepalived.conf
Global_defs {
Notification_email {
[Email protected]
}
Notification_email_from [email protected]
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
router_id Mysql_ha #标识, double master Same
}
Vrrp_instance Vi_1 {
State BACKUP #两台都设置BACKUP
Interface eth0
virtual_router_id Wuyi #主备相同
Priority #优先级, backup settings 50
Advert_int 1
Nopreempt #不主动抢占资源, only in master this high priority setting, backup does not need to set
Authentication {
Auth_type PASS
Auth_pass 1111
}
virtual_ipaddress {
192.168.119.138
}
}
Virtual_server 192.168.0.204 3306 {
Delay_loop 2
#lb_algo RR #LVS算法, we're closed.
#lb_kind DR #就是这项导致上述的现象, LVS mode, if not turned off, the standby server cannot connect to master MySQL via VIP
Persistence_timeout #同一IP的连接60秒内被分配到同一台真实服务器
Protocol TCP
Real_server 192.168.119.23 3306 {#检测本地mysql, Backup also write to detect local MySQL
Weight 3
Notify_down/usr/local/keepalived/mysql.sh #当mysq服down时, execute this script, kill the keepalived implementation switch, or add other commands or scripts.
Tcp_check {
Connect_timeout 3 #连接超时
Nb_get_retry 3 #重试次数
Delay_before_retry 3 #重试间隔时间
}
}
Although the problem is solved, but do not understand why this? I use the same version of MySQL and keepalived in the Rhel 6.0 X64 environment to test that this problem does not occur. Ask the master to appear the answer.
This article from "Heric" blog, declined reprint!
Keepalived+mysql Backup server can ping through VIP but Telnet vip+3306 failure issue