1- <!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.8 2009/05/14 20:31:09 heikki Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.9 2009/05/14 21:59:22 tgl Exp $ -->
22
33<sect1 id="pgstandby">
44 <title>pg_standby</title>
@@ -93,20 +93,20 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv
9393 the <replaceable>archivelocation</> directory must be writable too.
9494 </para>
9595 <para>
96- There are two ways to fail over a <quote>warm standby</> database server.
97- You control the type of failover with the contents of the trigger file :
96+ There are two ways to fail over to a <quote>warm standby</> database server
97+ when the master server fails :
9898
9999 <variablelist>
100100 <varlistentry>
101101 <term>Smart Failover</term>
102102 <listitem>
103103 <para>
104- In smart failover, the server is brought up after applying all
105- WAL files available in the archive. This results in zero data loss,
106- even if the standby server has fallen behind, but if there is a lot
107- unapplied WAL the recovery can take a long time. To trigger a smart
108- failover, create a trigger file containing the word <literal>smart</>,
109- or just leave it empty.
104+ In smart failover, the server is brought up after applying all WAL
105+ files available in the archive. This results in zero data loss, even if
106+ the standby server has fallen behind, but if there is a lot of
107+ unapplied WAL it can be a long time before the standby server becomes
108+ ready. To trigger a smart failover, create a trigger file containing
109+ the word <literal>smart</>, or just create it and leave it empty.
110110 </para>
111111 </listitem>
112112 </varlistentry>
@@ -117,7 +117,10 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv
117117 In fast failover, the server is brought up immediately. Any WAL files
118118 in the archive that have not yet been applied will be ignored, and
119119 all transactions in those files are lost. To trigger a fast failover,
120- write the word <literal>fast</> into the trigger file.
120+ create a trigger file and write the word <literal>fast</> into it.
121+ <application>pg_standby</> can also be configured to execute a fast
122+ failover automatically if no new WAL file appears within a defined
123+ interval.
121124 </para>
122125 </listitem>
123126 </varlistentry>
@@ -208,7 +211,7 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv
208211 <entry><literal>-t</> <replaceable>triggerfile</></entry>
209212 <entry>none</entry>
210213 <entry>
211- Specify a trigger file whose presence should perform failover.
214+ Specify a trigger file whose presence should cause failover.
212215 It is recommended that you use a structured filename to
213216 avoid confusion as to which server is being triggered
214217 when multiple servers exist on the same system; for example
@@ -240,6 +243,7 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv
240243archive_command = 'cp %p .../archive/%f'
241244
242245restore_command = 'pg_standby -l -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f %p %r 2>>standby.log'
246+
243247recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
244248 </programlisting>
245249 <para>
@@ -289,11 +293,14 @@ recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
289293archive_command = 'copy %p ...\\archive\\%f'
290294
291295restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p %r 2>>standby.log'
296+
297+ recovery_end_command = 'del C:\pgsql.trigger.5442'
292298 </programlisting>
293299 <para>
294300 Note that backslashes need to be doubled in the
295301 <literal>archive_command</>, but <emphasis>not</emphasis> in the
296- <literal>restore_command</>. This will:
302+ <literal>restore_command</> or <literal>recovery_end_command</>.
303+ This will:
297304 </para>
298305 <itemizedlist>
299306 <listitem>
@@ -318,6 +325,11 @@ restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p
318325 and perform failover according to its content
319326 </para>
320327 </listitem>
328+ <listitem>
329+ <para>
330+ remove the trigger file when recovery ends
331+ </para>
332+ </listitem>
321333 <listitem>
322334 <para>
323335 remove no-longer-needed files from the archive directory
@@ -335,7 +347,7 @@ restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p
335347 </para>
336348
337349 <para>
338- Using the Since the Windows example uses <literal>copy</> at both ends, either
350+ Since the Windows example uses <literal>copy</> at both ends, either
339351 or both servers might be accessing the archive directory across the
340352 network.
341353 </para>
@@ -356,6 +368,11 @@ restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p
356368 <literal>-k</literal> option must be used if archive cleanup is
357369 required. This option remains available in 8.3, but its use is deprecated.
358370 </para>
371+ <para>
372+ <productname>PostgreSQL</> 8.4 provides the
373+ <literal>recovery_end_command</literal> option. Without this option
374+ a leftover trigger file can be hazardous.
375+ </para>
359376 </sect2>
360377
361378 <sect2>
0 commit comments