mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
* there was a bug in the way the backup servers were handled. They
were erroneously load-balanced while the doc said the opposite. Since load-balanced backup servers is one of the features some people have been asking for, the problem was fixed to reflect the documented behaviour and a new option 'allbackups' was introduced to provide the feature to those who need it.
This commit is contained in:
parent
b45124729a
commit
3481c46368
@ -2,9 +2,9 @@
|
||||
H A - P r o x y
|
||||
Reference Manual
|
||||
-------------------
|
||||
version 1.2.8
|
||||
version 1.2.9
|
||||
willy tarreau
|
||||
2006/01/29
|
||||
2006/03/01
|
||||
|
||||
============
|
||||
| Abstract |
|
||||
@ -880,8 +880,10 @@ a backup server, clients assigned to this server will stick to it even when the
|
||||
other ones come back. Conversely, if no cookie is assigned to such a server,
|
||||
the clients will get their cookies removed (empty cookie = removal), and will
|
||||
be balanced against other servers once they come back. Please note that there
|
||||
is no load-balancing among backup servers. If there are several backup servers,
|
||||
the second one will only be used when the first one dies, and so on.
|
||||
is no load-balancing among backup servers by default. If there are several
|
||||
backup servers, the second one will only be used when the first one dies, and
|
||||
so on. To force load-balancing between backup servers, specify the 'allbackups'
|
||||
option.
|
||||
|
||||
Since version 1.1.17, it is also possible to visually check the status of all
|
||||
servers at once. For this, you just have to send a SIGHUP signal to the proxy.
|
||||
@ -979,6 +981,18 @@ Examples :
|
||||
server srv1 192.168.1.1 check port 25 inter 30000 rise 1 fall 2
|
||||
server srv2 192.168.1.2 backup
|
||||
|
||||
# Load-balancing using a backup pool (requires haproxy 1.2.9)
|
||||
listen http_proxy 0.0.0.0:80
|
||||
mode http
|
||||
balance roundrobin
|
||||
option httpchk
|
||||
server inst1 192.168.1.1:80 cookie s1 check
|
||||
server inst2 192.168.1.2:80 cookie s2 check
|
||||
server inst3 192.168.1.3:80 cookie s3 check
|
||||
server back1 192.168.1.10:80 check backup
|
||||
server back2 192.168.1.11:80 check backup
|
||||
option allbackups # all backups will be used
|
||||
|
||||
|
||||
3.2) Redistribute connections in case of failure
|
||||
------------------------------------------------
|
||||
|
@ -2,9 +2,9 @@
|
||||
H A - P r o x y
|
||||
Manuel de référence
|
||||
-------------------
|
||||
version 1.2.8
|
||||
version 1.2.9
|
||||
willy tarreau
|
||||
2006/01/29
|
||||
2006/03/01
|
||||
|
||||
================
|
||||
| Introduction |
|
||||
@ -877,12 +877,13 @@ utilis
|
||||
ajouter le mot clé "backup" sur la ligne de définition du serveur. Un serveur
|
||||
de secours n'est appelé que lorsque tous les serveurs normaux, ainsi que tous
|
||||
les serveurs de secours qui le précèdent sont hors d'usage. Il n'y a donc pas
|
||||
de répartition de charge entre des serveurs de secours. Ce type de serveurs
|
||||
peut servir à retourner des pages d'indisponibilité de service. Dans ce cas,
|
||||
il est préférable de ne pas affecter de cookie, afin que les clients qui le
|
||||
rencontrent n'y soient pas affectés définitivement. Le fait de ne pas mettre
|
||||
de cookie envoie un cookie vide, ce qui a pour effet de supprimer un éventuel
|
||||
cookie affecté précédemment.
|
||||
de répartition de charge entre des serveurs de secours par défaut. A partir
|
||||
de la version 1.2.9, il est possible de les utiliser simultanément grâce à
|
||||
l'option 'allbackups'. Ce type de serveurs peut servir à retourner des pages
|
||||
d'indisponibilité de service. Dans ce cas, il est préférable de ne pas affecter
|
||||
de cookie, afin que les clients qui le rencontrent n'y soient pas affectés
|
||||
définitivement. Le fait de ne pas mettre de cookie envoie un cookie vide, ce
|
||||
qui a pour effet de supprimer un éventuel cookie affecté précédemment.
|
||||
|
||||
Depuis la version 1.1.22, il est possible d'envoyer les tests de fonctionnement
|
||||
vers un port différent de celui de service. C'est nécessaire principalement
|
||||
@ -989,6 +990,18 @@ Exemples :
|
||||
server srv1 192.168.1.1 check port 25 inter 30000 rise 1 fall 2
|
||||
server srv2 192.168.1.2 backup
|
||||
|
||||
# Utilisation d'un groupe de serveurs pour le backup (nécessite haproxy 1.2.9)
|
||||
listen http_proxy 0.0.0.0:80
|
||||
mode http
|
||||
balance roundrobin
|
||||
option httpchk
|
||||
server inst1 192.168.1.1:80 cookie s1 check
|
||||
server inst2 192.168.1.2:80 cookie s2 check
|
||||
server inst3 192.168.1.3:80 cookie s3 check
|
||||
server back1 192.168.1.10:80 check backup
|
||||
server back2 192.168.1.11:80 check backup
|
||||
option allbackups # all backups will be used
|
||||
|
||||
|
||||
3.2) Reconnexion vers un répartiteur en cas d'échec direct
|
||||
----------------------------------------------------------
|
||||
|
13
haproxy.c
13
haproxy.c
@ -325,6 +325,7 @@ int strlcpy2(char *dst, const char *src, int size) {
|
||||
#define PR_O_CHK_CACHE 0x00020000 /* require examination of cacheability of the 'set-cookie' field */
|
||||
#define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side sessions */
|
||||
#define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side sessions */
|
||||
#define PR_O_USE_ALL_BK 0x00100000 /* load-balance between backup servers */
|
||||
|
||||
/* various session flags */
|
||||
#define SN_DIRECT 0x00000001 /* connection made on the server matching the client cookie */
|
||||
@ -1778,6 +1779,14 @@ static inline struct server *find_server(struct proxy *px) {
|
||||
return srv;
|
||||
srv = srv->next;
|
||||
} while (srv != px->cursrv);
|
||||
|
||||
/* By default, we look for the first backup server if all others are
|
||||
* DOWN. But in some cases, it may be desirable to load-balance across
|
||||
* all backup servers.
|
||||
*/
|
||||
if (!(px->options & PR_O_USE_ALL_BK))
|
||||
srv = px->srv;
|
||||
|
||||
} while (ignore_backup--);
|
||||
return NULL;
|
||||
}
|
||||
@ -6590,6 +6599,10 @@ int cfg_parse_listen(char *file, int linenum, char **args) {
|
||||
/* enable TCP keep-alives on server sessions */
|
||||
curproxy->options |= PR_O_TCP_SRV_KA;
|
||||
}
|
||||
else if (!strcmp(args[1], "allbackups")) {
|
||||
/* Use all backup servers simultaneously */
|
||||
curproxy->options |= PR_O_USE_ALL_BK;
|
||||
}
|
||||
else if (!strcmp(args[1], "httpchk")) {
|
||||
/* use HTTP request to check servers' health */
|
||||
if (curproxy->check_req != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user