1<chapter id="follow-new-primary">
2 <title>Following a new primary</title>
3
4 <indexterm>
5  <primary>Following a new primary</primary>
6  <seealso>repmgr standby follow</seealso>
7 </indexterm>
8
9 <para>
10   Following the failure or removal of the replication cluster's existing primary
11   server, <xref linkend="repmgr-standby-follow"/> can be used to make &quot;orphaned&quot; standbys
12   follow the new primary and catch up to its current state.
13 </para>
14 <para>
15  To demonstrate this, assuming a replication cluster in the same state as the
16  end of the preceding section (<xref linkend="promoting-standby"/>),
17  execute this:
18  <programlisting>
19    $ repmgr -f /etc/repmgr.conf standby follow
20    INFO: changing node 3's primary to node 2
21    NOTICE: restarting server using "pg_ctl -l /var/log/postgresql/startup.log -w -D '/var/lib/postgresql/data' restart"
22    waiting for server to shut down......... done
23    server stopped
24    waiting for server to start.... done
25    server started
26    NOTICE: STANDBY FOLLOW successful
27    DETAIL: node 3 is now attached to node 2
28  </programlisting>
29 </para>
30 <para>
31   The standby is now replicating from the new primary and
32   <command><link linkend="repmgr-cluster-show">repmgr cluster show</link></command>
33   output reflects this:
34   <programlisting>
35    $ repmgr -f /etc/repmgr.conf cluster show
36     ID | Name  | Role    | Status    | Upstream | Location | Connection string
37    ----+-------+---------+-----------+----------+----------+--------------------------------------
38     1  | node1 | primary | - failed  |          | default  | host=node1 dbname=repmgr user=repmgr
39     2  | node2 | primary | * running |          | default  | host=node2 dbname=repmgr user=repmgr
40     3  | node3 | standby |   running | node2    | default  | host=node3 dbname=repmgr user=repmgr</programlisting>
41 </para>
42 <para>
43  Note that with cascading replication, <command>repmgr standby follow</command> can also be
44  used to detach a standby from its current upstream server and follow the
45  primary. However it's currently not possible to have it follow another standby;
46  we hope to improve this in a future release.
47 </para>
48
49</chapter>
50