I have a MariaDB cluster with HaProxy. I need to redirect my clients to other machines everyday between 07.00-07.10 due to heavy working cronjobs. For example i have 3 server that ips are 192.168.1.2,192.168.1.3,192.168.1.4. between 07.00-07.10 my 192.168.1.1 application server shouldn't use 192.168.1.2. How can i do it?
Asked
Active
Viewed 457 times
1 Answers
2
I think, easiest way is to use haproxy-agent. Example:
haproxy-section:
listen mysql
bind *:3306
mode tcp
option tcplog
balance leastconn
default-server port 3306 agent-check agent-port 6789 weight 100 inter 1000 on-marked-down shutdown-sessions
server server1 192.168.1.2 check
server server2 192.168.1.3 check
server server3 192.168.1.4 check
/etc/xinet.d/haproxy-agent on mysql-hosts:
service haproxy-agent
{
disable = no
flags = REUSE
log_on_failure += USERID
port = 6789
server = /usr/local/bin/haproxy-agent
socket_type = stream
type = UNLISTED
user = nobody
wait = no
}
/usr/local/bin/haproxy-agent:
#!/bin/bash
RES="up 100%"
TIME=$(date "+%H%M" | sed 's/^0\+//')
[[ "${TIME}" -ge 700 && "${TIME}" -le 710 ]] && RES="down"
echo "${RES}"
Agent's code, of course, should be a little more intelligent not to overlap closing RDBMS-hosts. BTW, agent answer is optional to haproxy, so if it does not respond - ok, haproxy just ignore this fact.

GreyWolf
- 76
- 3