3.5. Peers

  1. It is possible to propagate entries of any data-types in stick-tables between
  2. several haproxy instances over TCP connections in a multi-master fashion. Each
  3. instance pushes its local updates and insertions to remote peers. The pushed
  4. values overwrite remote ones without aggregation. Interrupted exchanges are
  5. automatically detected and recovered from the last known point.
  6. In addition, during a soft restart, the old process connects to the new one
  7. using such a TCP connection to push all its entries before the new process
  8. tries to connect to other peers. That ensures very fast replication during a
  9. reload, it typically takes a fraction of a second even for large tables.
  10. Note that Server IDs are used to identify servers remotely, so it is important
  11. that configurations look similar or at least that the same IDs are forced on
  12. each server on all participants.

peers

  1. Creates a new peer list with name <peersect>. It is an independent section,
  2. which is referenced by one or more stick-tables.

bind [

]: [, …] [param*]

  1. Defines the binding parameters of the local peer of this "peers" section.
  2. Such lines are not supported with "peer" line in the same "peers" section.

disabled

  1. Disables a peers section. It disables both listening and any synchronization
  2. related to this section. This is provided to disable synchronization of stick
  3. tables without having to comment out all "peers" references.

default-bind [param*]

  1. Defines the binding parameters for the local peer, excepted its address.

default-server [param*]

  1. Change default options for a server in a "peers" section.

Arguments:

  1. <param*> is a list of parameters for this server. The "default-server"
  2. keyword accepts an important number of options and has a complete
  3. section dedicated to it. Please refer to section 5 for more
  4. details.

See also:server

“ and section 5 about server options

enable

  1. This re-enables a disabled peers section which was previously disabled.

peer : [param*]

  1. Defines a peer inside a peers section.
  2. If <peername> is set to the local peer name (by default hostname, or forced
  3. using "-L" command line option), haproxy will listen for incoming remote peer
  4. connection on <ip>:<port>. Otherwise, <ip>:<port> defines where to connect to
  5. to join the remote peer, and <peername> is used at the protocol level to
  6. identify and validate the remote peer on the server side.
  7.  
  8. During a soft restart, local peer <ip>:<port> is used by the old instance to
  9. connect the new one and initiate a complete replication (teaching process).
  10.  
  11. It is strongly recommended to have the exact same peers declaration on all
  12. peers and to only rely on the "-L" command line argument to change the local
  13. peer name. This makes it easier to maintain coherent configuration files
  14. across all peers.
  15.  
  16. You may want to reference some environment variables in the address
  17. parameter, see section 2.3 about environment variables.
  18.  
  19. Note: "peer" keyword may transparently be replaced by "server" keyword (see
  20. "server" keyword explanation below).

server [:] [param*]

  1. As previously mentioned, "peer" keyword may be replaced by "server" keyword
  2. with a support for all "server" parameters found in 5.2 paragraph.
  3. If the underlying peer is local, <ip>:<port> parameters must not be present.
  4. These parameters must be provided on a "bind" line (see "bind" keyword
  5. of this "peers" section).
  6. Some of these parameters are irrelevant for "peers" sections.

Example:

  1. # The old way.
  2. peers mypeers
  3. peer haproxy1 192.168.0.1:1024
  4. peer haproxy2 192.168.0.2:1024
  5. peer haproxy3 10.2.0.1:1024
  6. backend mybackend
  7. mode tcp
  8. balance roundrobin
  9. stick-table type ip size 20k peers mypeers
  10. stick on src
  11. server srv1 192.168.0.30:80
  12. server srv2 192.168.0.31:80
  13. Example:
  14. peers mypeers
  15. bind 127.0.0.11:10001 ssl crt mycerts/pem
  16. default-server ssl verify none
  17. server hostA 127.0.0.10:10000
  18. server hostB #local peer

table type {ip | integer | string [len ] | binary [len ]} size [expire ] [nopurge] [store ]*

  1. Configure a stickiness table for the current section. This line is parsed
  2. exactly the same way as the "stick-table" keyword in others section, except
  3. for the "peers" argument which is not required here and with an additional
  4. mandatory first parameter to designate the stick-table. Contrary to others
  5. sections, there may be several "table" lines in "peers" sections (see also
  6. "stick-table" keyword).
  7.  
  8. Also be aware of the fact that "peers" sections have their own stick-table
  9. namespaces to avoid collisions between stick-table names identical in
  10. different "peers" section. This is internally handled prepending the "peers"
  11. sections names to the name of the stick-tables followed by a '/' character.
  12. If somewhere else in the configuration file you have to refer to such
  13. stick-tables declared in "peers" sections you must use the prefixed version
  14. of the stick-table name as follows:
  15.  
  16. peers mypeers
  17. peer A ...
  18. peer B ...
  19. table t1 ...
  20.  
  21. frontend fe1
  22. tcp-request content track-sc0 src table mypeers/t1
  23.  
  24. This is also this prefixed version of the stick-table names which must be
  25. used to refer to stick-tables through the CLI.
  26.  
  27. About "peers" protocol, as only "peers" belonging to the same section may
  28. communicate with each others, there is no need to do such a distinction.
  29. Several "peers" sections may declare stick-tables with the same name.
  30. This is shorter version of the stick-table name which is sent over the network.
  31. There is only a '/' character as prefix to avoid stick-table name collisions between
  32. stick-tables declared as backends and stick-table declared in "peers" sections
  33. as follows in this weird but supported configuration:
  34.  
  35. peers mypeers
  36. peer A ...
  37. peer B ...
  38. table t1 type string size 10m store gpc0
  39.  
  40. backend t1
  41. stick-table type string size 10m store gpc0 peers mypeers
  42.  
  43. Here "t1" table declared in "mypeeers" section has "mypeers/t1" as global name.
  44. "t1" table declared as a backend as "t1" as global name. But at peer protocol
  45. level the former table is named "/t1", the latter is again named "t1".