Class: RhaproxyPeers
- Inherits:
-
Object
- Object
- RhaproxyPeers
- Defined in:
- lib/rhaproxy/peers.rb
Overview
It is possible to synchronize server entries 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. 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. 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.
Instance Attribute Summary collapse
-
#name ⇒ Object
name <peersect> Creates a new peer name <peersect>.
-
#peer ⇒ Object
peer <peername> <ip>:<port> Defines a peer inside a peers section.
-
#peers ⇒ Object
peers <peersect> Creates a new peer list with name <peersect>.
Instance Method Summary collapse
-
#config ⇒ Object
Compile the HAproxy peers configuration.
-
#initialize ⇒ RhaproxyPeers
constructor
Returns a new RhaproxyPeers Object.
Constructor Details
#initialize ⇒ RhaproxyPeers
Returns a new RhaproxyPeers Object
65 66 |
# File 'lib/rhaproxy/peers.rb', line 65 def initialize() end |
Instance Attribute Details
#name ⇒ Object
name <peersect>
Creates a new peer name <peersect>. It is an independant section,
which is referenced by one or more stick-tables.
32 33 34 |
# File 'lib/rhaproxy/peers.rb', line 32 def name @name end |
#peer ⇒ Object
peer <peername> <ip>:<port>
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.
60 61 62 |
# File 'lib/rhaproxy/peers.rb', line 60 def peer @peer end |
#peers ⇒ Object
peers <peersect>
Creates a new peer list with name <peersect>. It is an independant section,
which is referenced by one or more stick-tables.
This is under the peers_section.
41 42 43 |
# File 'lib/rhaproxy/peers.rb', line 41 def peers @peers end |
Instance Method Details
#config ⇒ Object
Compile the HAproxy peers configuration
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rhaproxy/peers.rb', line 71 def config if @name conf = option_string() return conf else puts "no peers section name defined" return false end end |