~ubuntu-branches/ubuntu/lucid/postgresql-8.4/lucid-proposed

« back to all changes in this revision

Viewing changes to doc/src/sgml/pgstandby.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-05-19 14:03:37 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090519140337-wp9u2si99uppeb81
Tags: 8.4~beta2-2
* Second public beta of 8.4.
* debian/control: Slightly lower the dependencies for postgresql-common to
  >= 98~, so that backports also match.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- $PostgreSQL$ -->
 
1
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.9 2009/05/14 21:59:22 tgl Exp $ -->
2
2
 
3
3
<sect1 id="pgstandby">
4
4
 <title>pg_standby</title>
92
92
   is specified,
93
93
   the <replaceable>archivelocation</> directory must be writable too.
94
94
  </para>
 
95
  <para>
 
96
   There are two ways to fail over to a <quote>warm standby</> database server
 
97
   when the master server fails:
 
98
 
 
99
   <variablelist>
 
100
    <varlistentry>
 
101
     <term>Smart Failover</term>
 
102
     <listitem>
 
103
      <para>
 
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.
 
110
      </para>
 
111
     </listitem>
 
112
    </varlistentry>
 
113
    <varlistentry>
 
114
     <term>Fast Failover</term>
 
115
     <listitem>
 
116
      <para>
 
117
       In fast failover, the server is brought up immediately. Any WAL files
 
118
       in the archive that have not yet been applied will be ignored, and
 
119
       all transactions in those files are lost. To trigger a fast failover,
 
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.
 
124
      </para>
 
125
     </listitem>
 
126
    </varlistentry>
 
127
   </variablelist>
 
128
  </para>
95
129
 
96
130
  <table>
97
131
   <title><application>pg_standby</> options</title>
177
211
      <entry><literal>-t</> <replaceable>triggerfile</></entry>
178
212
      <entry>none</entry>
179
213
      <entry>
180
 
       Specify a trigger file whose presence should cause recovery to end
181
 
       whether or not the next WAL file is available.
 
214
       Specify a trigger file whose presence should cause failover.
182
215
       It is recommended that you use a structured filename to
183
216
       avoid confusion as to which server is being triggered
184
217
       when multiple servers exist on the same system; for example
190
223
      <entry>0</entry>
191
224
      <entry>
192
225
       Set the maximum number of seconds to wait for the next WAL file,
193
 
       after which recovery will end and the standby will come up.
 
226
       after which a fast failover will be performed.
194
227
       A setting of zero (the default) means wait forever.
195
228
       The default setting is not necessarily recommended;
196
229
       consult <xref linkend="warm-standby"> for discussion.
210
243
archive_command = 'cp %p .../archive/%f'
211
244
 
212
245
restore_command = 'pg_standby -l -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f %p %r 2>>standby.log'
 
246
 
 
247
recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
213
248
  </programlisting>
214
249
  <para>
215
250
   where the archive directory is physically located on the standby server,
236
271
   <listitem>
237
272
    <para>
238
273
     stop waiting only when a trigger file called
239
 
     <filename>/tmp/pgsql.trigger.5442</> appears
 
274
     <filename>/tmp/pgsql.trigger.5442</> appears,
 
275
     and perform failover according to its content
 
276
    </para>
 
277
   </listitem>
 
278
   <listitem>
 
279
    <para>
 
280
     remove the trigger file when recovery ends
240
281
    </para>
241
282
   </listitem>
242
283
   <listitem>
252
293
archive_command = 'copy %p ...\\archive\\%f'
253
294
 
254
295
restore_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'
255
298
  </programlisting>
256
299
  <para>
257
300
   Note that backslashes need to be doubled in the
258
301
   <literal>archive_command</>, but <emphasis>not</emphasis> in the
259
 
   <literal>restore_command</>.  This will:
 
302
   <literal>restore_command</> or <literal>recovery_end_command</>.
 
303
   This will:
260
304
  </para>
261
305
  <itemizedlist>
262
306
   <listitem>
277
321
   <listitem>
278
322
    <para>
279
323
     stop waiting only when a trigger file called
280
 
     <filename>C:\pgsql.trigger.5442</> appears
 
324
     <filename>C:\pgsql.trigger.5442</> appears,
 
325
     and perform failover according to its content
 
326
    </para>
 
327
   </listitem>
 
328
   <listitem>
 
329
    <para>
 
330
     remove the trigger file when recovery ends
281
331
    </para>
282
332
   </listitem>
283
333
   <listitem>
297
347
  </para>
298
348
 
299
349
  <para>
300
 
   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
301
351
   or both servers might be accessing the archive directory across the
302
352
   network.
303
353
  </para>
318
368
   <literal>-k</literal> option must be used if archive cleanup is
319
369
   required.  This option remains available in 8.3, but its use is deprecated.
320
370
  </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>
321
376
 </sect2>
322
377
 
323
378
 <sect2>