【TiDB 使用环境】生产环境 /测试/ Poc
101和102服务器部署两个tiproxy节点,使用vip实现高可用,vip是124,阿里云服务器部署。
使用vip连接时不时会出现以下情况
mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id: 40
Current database: *** NONE ***
101和102分别部署了tiproxy并安装keepalived,各自配置如下
tiproxy分别增加以下配置
[ha]
interface = "eth0"
virtual-ip = "******.124/24"
keepalived 配置
master
[root@MWDB-tiproxy1 ~]# 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 eth0
virtual_router_id 51
nopreempt
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
unicast_src_ip ******.101 # 本实例的私网IP地址,本示例配置为192.168.0.25
unicast_peer {
******.102 # 对端实例的私网IP地址,本示例配置为192.168.0.26;如有多台备用ECS实例,需声明所有对端实例的IP,每个地址单独占一行,无需逗号或其他分隔符。
}
virtual_ipaddress {
******.124 # 虚拟IP地址,配置为HaVip的IP地址,本示例为192.168.0.24
}
garp_master_delay 1 # 当切为主实例后多久更新ARP缓存,单位为秒
garp_master_refresh 5 # 发送ARP报文的时间间隔,单位为秒
track_interface {
eth0 # 绑定VIP的网卡,本示例配置为eth0
}
}
backup
[root@MWDB-tiproxy2 ~]# 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 BACKUP
interface eth0
virtual_router_id 55
nopreempt
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
unicast_src_ip ******.102 # 本实例的私网IP地址,本示例配置为192.168.0.25
unicast_peer {
******.101 # 对端实例的私网IP地址,本示例配置为192.168.0.26;如有多台备用ECS实例,需声明所有对端实例的IP,每个地址单独占一行,无需逗号或其他分隔符。
}
virtual_ipaddress {
******.124 # 虚拟IP地址,配置为HaVip的IP地址,本示例为192.168.0.24
}
garp_master_delay 1 # 当切为主实例后多久更新ARP缓存,单位为秒
garp_master_refresh 5 # 发送ARP报文的时间间隔,单位为秒
track_interface {
eth0 # 绑定VIP的网卡,本示例配置为eth0
}
}