3.5. Peers
- It is possible to propagate entries of any data-types in stick-tables between
- several haproxy instances over TCP connections in a multi-master fashion. Each
- instance pushes its local updates and insertions to remote peers. The pushed
- values overwrite remote ones without aggregation. Interrupted exchanges are
- automatically detected and recovered from the last known point.
- In addition, during a soft restart, the old process connects to the new one
- using such a TCP connection to push all its entries before the new process
- tries to connect to other peers. That ensures very fast replication during a
- reload, it typically takes a fraction of a second even for large tables.
- Note that Server IDs are used to identify servers remotely, so it is important
- that configurations look similar or at least that the same IDs are forced on
- each server on all participants.
- Creates a new peer list with name <peersect>. It is an independent section,
- which is referenced by one or more stick-tables.
bind [
]:
- Disables a peers section. It disables both listening and any synchronization
- related to this section. This is provided to disable synchronization of stick
- tables without having to comment out all "peers" references.
default-bind [param*]
- Defines the binding parameters for the local peer, excepted its address.
default-server [param*]
- Change default options for a server in a "peers" section.
Arguments:
- <param*> is a list of parameters for this server. The "default-server
"
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
- keyword accepts an important number of options and has a complete
- section dedicated to it. Please refer to section 5 for more
- details.
See also: “server
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
“ and section 5 about server options
- This re-enables a disabled peers section which was previously disabled.
peer
- Defines a peer inside a peers section.
- If <peername> is set to the local peer name (by default hostname, or forced
- using "-L" command line option), haproxy will listen for incoming remote peer
- connection on <ip>:<port>. Otherwise, <ip>:<port> defines where to connect to
- to join the remote peer, and <peername> is used at the protocol level to
- identify and validate the remote peer on the server side.
- During a soft restart, local peer <ip>:<port> is used by the old instance to
- connect the new one and initiate a complete replication (teaching process).
- It is strongly recommended to have the exact same peers declaration on all
- peers and to only rely on the "-L" command line argument to change the local
- peer name. This makes it easier to maintain coherent configuration files
- across all peers.
- You may want to reference some environment variables in the address
- parameter, see section 2.3 about environment variables.
- Note: "peer" keyword may transparently be replaced by "server
" keyword (see
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
- "server
" keyword explanation below).
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
server
- As previously mentioned, "peer" keyword may be replaced by "server
" keyword
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
- with a support for all "server
" parameters found in 5.2 paragraph.
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
- If the underlying peer is local, <ip>:<port> parameters must not be present.
- These parameters must be provided on a "bind
" line (see "bind
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
" keyword
- This keyword is available in sections :
- Peers
- Alphabetically sorted keywords reference
- of this "peers" section).
- Some of these parameters are irrelevant for "peers" sections.
Example:
# The old way.
peers mypeers
peer haproxy1 192.168.0.1:1024
peer haproxy2 192.168.0.2:1024
peer haproxy3 10.2.0.1:1024
backend mybackend
mode tcp
balance roundrobin
stick-table type ip size 20k peers mypeers
stick on src
server srv1 192.168.0.30:80
server srv2 192.168.0.31:80
Example:
peers mypeers
bind 127.0.0.11:10001 ssl crt mycerts/pem
default-server ssl verify none
server hostA 127.0.0.10:10000
server hostB #local peer
table
- Configure a stickiness table for the current section. This line is parsed
- exactly the same way as the "stick-table" keyword in others section, except
- for the "peers" argument which is not required here and with an additional
- mandatory first parameter to designate the stick-table. Contrary to others
- sections, there may be several "table" lines in "peers" sections (see also
- "stick-table" keyword).
- Also be aware of the fact that "peers" sections have their own stick-table
- namespaces to avoid collisions between stick-table names identical in
- different "peers" section. This is internally handled prepending the "peers"
- sections names to the name of the stick-tables followed by a '/' character.
- If somewhere else in the configuration file you have to refer to such
- stick-tables declared in "peers" sections you must use the prefixed version
- of the stick-table name as follows:
- peers mypeers
- peer A ...
- peer B ...
- table t1 ...
- frontend fe1
- tcp-request content track-sc0 src table mypeers/t1
- This is also this prefixed version of the stick-table names which must be
- used to refer to stick-tables through the CLI.
- About "peers" protocol, as only "peers" belonging to the same section may
- communicate with each others, there is no need to do such a distinction.
- Several "peers" sections may declare stick-tables with the same name.
- This is shorter version of the stick-table name which is sent over the network.
- There is only a '/' character as prefix to avoid stick-table name collisions between
- stick-tables declared as backends and stick-table declared in "peers" sections
- as follows in this weird but supported configuration:
- peers mypeers
- peer A ...
- peer B ...
- table t1 type string size 10m store gpc0
- backend t1
- stick-table type string size 10m store gpc0 peers mypeers
- Here "t1" table declared in "mypeeers" section has "mypeers/t1" as global name.
- "t1" table declared as a backend as "t1" as global name. But at peer protocol
- level the former table is named "/t1", the latter is again named "t1".