@@ -43,8 +43,6 @@ or run the docker build command directly:
4343
4444 $ git clone https://github.com/citusdata/pg_auto_failover
4545 $ cd pg_auto_failover/docs/tutorial
46-
47- $ docker build -t pg_auto_failover:tutorial -f Dockerfile ../..
4846 $ docker-compose build
4947
5048Postgres failover with two nodes
@@ -74,7 +72,7 @@ following command:
7472
7573::
7674
77- $ docker-compose up
75+ $ docker-compose up app monitor node1 node2
7876
7977The command above starts the services up. The first service is the monitor
8078and is created with the command ``pg_autoctl create monitor ``. The options
@@ -196,6 +194,107 @@ And we can verify that we still have the data available::
196194 75
197195 (1 row)
198196
197+ Multiple Standbys Architectures
198+ -------------------------------
199+
200+ The ``docker-compose.yml `` file comes with a third node that you can bring
201+ up to obtain the following architecture:
202+
203+ .. figure :: ./tikz/arch-multi-standby.svg
204+ :alt: pg_auto_failover Architecture for a standalone PostgreSQL service
205+
206+ pg_auto_failover architecture with a primary and two standby nodes
207+
208+ Adding a second standby node
209+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
210+
211+ To run a second standby node, or a third Postgres node, simply run the
212+ following command:
213+
214+ ::
215+
216+ $ docker-compose up -d node3
217+
218+ We can see the resulting replication settings with the following command:
219+
220+ ::
221+
222+ $ docker-compose exec monitor pg_autoctl show settings
223+
224+ Context | Name | Setting | Value
225+ ----------+---------+---------------------------+-------------------------------------------------------------
226+ formation | default | number_sync_standbys | 1
227+ primary | node1 | synchronous_standby_names | 'ANY 1 (pgautofailover_standby_1, pgautofailover_standby_3)'
228+ node | node2 | candidate priority | 50
229+ node | node1 | candidate priority | 50
230+ node | node3 | candidate priority | 50
231+ node | node2 | replication quorum | true
232+ node | node1 | replication quorum | true
233+ node | node3 | replication quorum | true
234+
235+ Editing the replication settings while in production
236+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
237+
238+ It's then possible to change the production architecture obtained with
239+ playing with the :ref: `architecture_setup ` commands. Specifically, try the
240+ following command to change the candidate_priority of the node3 to zero, in
241+ order for it to never be a candidate for failover:
242+
243+ ::
244+
245+ $ docker-compose exec node3 pg_autoctl set candidate-priority 0 --name node3
246+
247+ To see the replication settings for all the nodes, the following command can
248+ be useful, and is described in more details in the :ref: `architecture_setup `
249+ section.
250+
251+ ::
252+
253+ $ docker-compose exec monitor pg_autoctl show settings
254+
255+ Context | Name | Setting | Value
256+ ----------+---------+---------------------------+-------------------------------------------------------------
257+ formation | default | number_sync_standbys | 1
258+ primary | node1 | synchronous_standby_names | 'ANY 1 (pgautofailover_standby_1, pgautofailover_standby_3)'
259+ node | node2 | candidate priority | 50
260+ node | node1 | candidate priority | 50
261+ node | node3 | candidate priority | 0
262+ node | node2 | replication quorum | true
263+ node | node1 | replication quorum | true
264+ node | node3 | replication quorum | true
265+
266+ Then in a separate terminal (but in the same directory, because of the way
267+ docker-compose works with projects), you can run the following watch
268+ command:
269+
270+ ::
271+
272+ $ docker-compose exec monitor pg_autoctl watch
273+
274+ And in the main terminal, while the watch command output is visible, you can
275+ run a switchover operation:
276+
277+ ::
278+
279+ $ docker-compose exec monitor pg_autoctl perform switchover
280+
281+ Getting familiar with those commands one of you next steps. The manual has
282+ coverage for them in the following links:
283+
284+ * :ref: `pg_autoctl_watch `
285+ * :ref: `pg_autoctl_show_state `
286+ * :ref: `pg_autoctl_show_settings `
287+ * :ref: `pg_autoctl_set_node_candidate_priority `
288+
289+ Cleanup
290+ -------
291+
292+ To dispose of the entire tutorial environment, just use the following command:
293+
294+ ::
295+
296+ $ docker-compose down
297+
199298Next steps
200299----------
201300
0 commit comments