aFlex and server-for-server backups
in aFleX
Posted by kberton
I have 3 primary app servers and 3 backup servers in a SLB Service Group. Let's call them A1/B1/C1 and A2/B2/C2. In normal operations, all traffic will be LB'd to A1/B1/C1 and A2/B2/C2 are backup servers that will only receive live traffic when there is a failure on any of the 3 primary servers. Service Group Priorities and Min Active Members can help out a great deal here, but there is a twist that I believe requires an aFlex. The requirement is that if A1 fails, it must be replaced by A2; if B1 fails, it must be replaced by B2; and so on.
What would the aFlex script to accomplish this look like?
I have 3 primary app servers and 3 backup servers in a SLB Service Group. Let's call them A1/B1/C1 and A2/B2/C2. In normal operations, all traffic will be LB'd to A1/B1/C1 and A2/B2/C2 are backup servers that will only receive live traffic when there is a failure on any of the 3 primary servers. Service Group Priorities and Min Active Members can help out a great deal here, but there is a twist that I believe requires an aFlex. The requirement is that if A1 fails, it must be replaced by A2; if B1 fails, it must be replaced by B2; and so on.
What would the aFlex script to accomplish this look like?
0
Comments
This would require some specific pre-configs on the "SLB-Server" and "SLB-Service Group".
Note: You won't be able to use Least Connection SLB algorithm.
1. Enter SLB Server configuration (I'm not sure you want that point)
2. Create Fake Servers with no health checks so they are always up
SLB Server Fake1 as 1.1.1.1
SLB Server Fake2 as 1.1.1.2
SLB Server Fake3 as 1.1.1.3
3. Create service groups for:
Fake Servers
sg-a with different servers/priority (see below)
sg-b with different servers/priority (see below)
sg-c with different servers/priority (see below)
Logic:
sg-a: Goes always to A1. If A1 down, go to A2. If A1+A2 down, go to B1/C1
sg-b: Goes always to B1. If B1 down, go to B2. If B1+B2 down, go to A1/C1
sg-c: Goes always to C1. If C1 down, go to C2. If C1+C2 down, go to A1/B1
4. Apply service group sg_fake to the VIP
5. Bind the aflex template to the VIP.
6. Save and test.
Your config will look similar to:
Note: I removed the SNAT that is not required.
Note: I added comments in front of the logs.
slb server a1 10.0.2.18
port 80 tcp
slb server a2 10.0.2.19
port 80 tcp
slb server b1 10.0.2.28
port 80 tcp
slb server b2 10.0.2.29
port 80 tcp
slb server c1 10.0.2.38
port 80 tcp
slb server c2 10.0.2.39
port 80 tcp
slb server fake1 1.1.1.1
no health-check
port 80 tcp
no health-check
slb server fake2 1.1.1.2
no health-check
port 80 tcp
no health-check
slb server fake3 1.1.1.3
no health-check
port 80 tcp
no health-check
slb service-group sg_fake tcp
member fake1:80
member fake2:80
member fake3:80
slb service-group sg_a tcp
member a1:80 priority 16
member a2:80 priority 5
member b1:80 priority 2
member c1:80 priority 2
member b2:80
member c2:80
slb service-group sg_b tcp
member b1:80 priority 16
member b2:80 priority 5
member a1:80 priority 2
member c1:80 priority 2
member a2:80
member c2:80
slb service-group sg_c tcp
member c1:80 priority 16
member c2:80 priority 5
member a1:80 priority 2
member b1:80 priority 2
member a2:80
member b2:80
slb virtual-server FailoverVIP 10.0.1.42
port 80 tcp
service-group sg_fake
aflex failover
aFleX script "failover"
when LB_SELECTED {
if {[IP::addr [LB::server addr] equals 1.1.1.1] } {
LB::reselect pool sg_a
#log "use pool sg_a"
}
if {[IP::addr [LB::server addr] equals 1.1.1.2] } {
LB::reselect pool sg_b
#log "use pool sg_b"
}
if {[IP::addr [LB::server addr] equals 1.1.1.3] } {
LB::reselect pool sg_c
#log "use pool sg_c"
}
}
when SERVER_CONNECTED {
#log "server = [IP::server_addr]"
}
In the same scenario if A1 is down request goes to A2 and If i want when A1 comes online all request has to move back to A1 and still A2 will be backup is this possible with aFlex if yes.
Can you please provide me sample aFlex.
Regards,
Kiran