Home > other >  Keepalived problem and binding VIP principle
Keepalived problem and binding VIP principle

Time:10-10

Background:
Company projects using nginx + tomcat + mysql, A recent project and new customers for the 2 sets of web server (to A and B to distinguish) network is not stable, A server in A substantial traffic activities, the machines are getting slower and slower response and then hang up directly, this server was only enabled nginx, equivalent to access only static images, so then decided to adopt (keepalived + nginx) + tomcat + mysql to build, after consulted many articles online, AB server according to the following structures:
A: xx, xx, xx. 10 (eth0, public) to do the master
B: xx, xx, xx. 11 (eth0, public) do backup
A and B are to install Nginx 1.10.1 + keepalived 1.3.2, IP, domain name binding to 10 keepalived VIP configured to 10, the configuration file is as follows:
A server 10:
 
! The Configuration File for keepalived

Global_defs {
Router_id hlwweb
}

Vrrp_script nginx_check {
The script "/etc/keepalived/nginx_check. Sh"
The interval of 2
Weight - 20
}

Vrrp_instance VI_1 {
The state BACKUP
Interface eth0
Virtual_router_id 51
11 McAst_src_ip xx. Xx. Xx.
The priority of 90
Advert_int 1
Nopreempt
The authentication {
The auth_type PASS
Auth_pass 1111
}

Track_script {
Nginx_check
}

Virtual_ipaddress {
Xx, xx. Xx. 11/8 scope global eth0
}
}

server 11 B:
! The Configuration File for keepalived 

Global_defs {
Router_id hlwweb
}

Vrrp_script nginx_check {
The script "/etc/keepalived/nginx_check. Sh"
The interval of 2
Weight - 20
}

Vrrp_instance VI_1 {
The state BACKUP
Interface eth0
Virtual_router_id 51
11 McAst_src_ip xx. Xx. Xx.
The priority of 100
Advert_int 1
Nopreempt
The authentication {
The auth_type PASS
Auth_pass 1111
}

Track_script {
Nginx_check
}

Virtual_ipaddress {
Xx, xx. Xx. 11/8 scope global eth0
}
}


problem phenomenon:
1, the start of A and B nginx and keepalived keepalived log normal, into the master 10, 11 into the backup, domain name is normal, stop 10 or 11 nginx, keepalived vrrp_script script will automatically restart in nginx;
2, stop to 11 keepalived service, there is no abnormal phenomenon;
3, stop 10 eth0 adapter ifdown eth0, drift, nginx server access domain jump to B;
4, stop 10 keepalived services, there have been two phenomenon, may be different from keepalived configuration:
4.1, 10 public IP will be lost, at this time B immediately show cut to the master server keepalived log, display the VIP card information, but it does not take effect, namely access domain name will be stuck, tip don't have access to A few seconds, unable to connect to A server at this time, also can't, about 5-10 minutes, drift, access to the domain name server jump to B nginx, SSH will connect to A server to server B;
4.2, B immediately show cut to the master server keepalived log, display the VIP card information, but it does not take effect, namely access to the domain name will still be access to A server nginx,

main problem:
1, the above problems, if someone has met, is related to network adapter configuration or keepalived configuration about? I put the AB master-slave refore, effect,
2, VIP configuration for A server IP whether there is A problem, see online say 3 IP, I here before due to room limits, only the public IP, then set the network IP, in eth1, should use network eth1 do configuration, how to do?
3, there are other colleagues to do a similar architecture, AB two servers outside network and IP network, individual bought a public IP as a VIP, so I want to ask is, if I have two servers, the configuration of the VIP is with someone else's public IP network segment, can be configured successful? If you can, what is this principle?
  • Related