Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51be14e

Browse files
committed
Add /contrib/pg_standby:
pg_standby is a production-ready program that can be used to create a Warm Standby server. Other configuration is required as well, all of which is described in the main server manual.Simon Riggs
1 parent528779a commit51be14e

File tree

3 files changed

+801
-0
lines changed

3 files changed

+801
-0
lines changed

‎contrib/pg_standby/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
PROGRAM = pg_standby
3+
OBJS= pg_standby.o
4+
5+
PG_CPPFLAGS = -I$(libpq_srcdir)
6+
PG_LIBS =$(libpq_pgport)
7+
8+
DOCS = README.pg_standby
9+
10+
ifdefUSE_PGXS
11+
PGXS :=$(shell pg_config --pgxs)
12+
include$(PGXS)
13+
else
14+
subdir = contrib/pg_standby
15+
top_builddir = ../..
16+
include$(top_builddir)/src/Makefile.global
17+
include$(top_srcdir)/contrib/contrib-global.mk
18+
endif

‎contrib/pg_standby/README.pg_standby

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
pg_standby README2006/12/08 Simon Riggs
2+
3+
o What is pg_standby?
4+
5+
pg_standby is a production-ready program that can be used to
6+
create a Warm Standby server. Other configuration is required
7+
as well, all of which is described in the main server manual.
8+
9+
The program is designed to be a wait-for restore_command,
10+
required to turn a normal archive recovery into a Warm Standby.
11+
Within the restore_command of the recovery.conf you could
12+
configure pg_standby in the following way:
13+
14+
restore_command = 'pg_standby archiveDir %f %p'
15+
16+
which would be sufficient to define that files will be restored
17+
from archiveDir.
18+
19+
o features of pg_standby
20+
21+
- pg_standby is written in C. So it is very portable
22+
and easy to install.
23+
24+
- supports copy or link from a directory (only)
25+
26+
- source easy to modify, with specifically designated
27+
sections to modify for your own needs, allowing
28+
interfaces to be written for additional Backup Archive Restore
29+
(BAR) systems
30+
31+
- portable: tested on Linux and Windows
32+
33+
o How to install pg_standby
34+
35+
$make
36+
$make install
37+
38+
o How to use pg_standby?
39+
40+
pg_standby should be used within the restore_command of the
41+
recovery.conf file. See the main PostgreSQL manual for details.
42+
43+
The basic usage should be like this:
44+
45+
restore_command = 'pg_standby archiveDir %f %p'
46+
47+
with the pg_standby command usage as
48+
49+
pg_standby [OPTION]... [ARCHIVELOCATION] [NEXTWALFILE] [XLOGFILEPATH]
50+
51+
When used within the restore_command the %f and %p macros
52+
will provide the actual file and path required for the restore/recovery.
53+
54+
o options
55+
56+
pg_standby has number of options.
57+
58+
-c
59+
use copy/cp command to restore WAL files from archive
60+
61+
-d
62+
debug/logging option.
63+
64+
-k numfiles
65+
Cleanup files in the archive so that we maintain no more
66+
than this many files in the archive.
67+
68+
You should be wary against setting this number too low,
69+
since this may mean you cannot restart the standby. This
70+
is because the last restartpoint marked in the WAL files
71+
may be many files in the past and can vary considerably.
72+
This should be set to a value exceeding the number of WAL
73+
files that can be recovered in 2*checkpoint_timeout seconds,
74+
according to the value in the warm standby postgresql.conf.
75+
It is wholly unrelated to the setting of checkpoint_segments
76+
on either primary or standby.
77+
78+
If in doubt, use a large value or do not set a value at all.
79+
80+
-l
81+
use ln command to restore WAL files from archive
82+
WAL files will remain in archive
83+
84+
Link is more efficient, but the default is copy to
85+
allow you to maintain the WAL archive for recovery
86+
purposes as well as high-availability.
87+
88+
This option uses the Windows Vista command mklink
89+
to provide a file-to-file symbolic link. -l will
90+
not work on versions of Windows prior to Vista.
91+
Use the -c option instead.
92+
see http://en.wikipedia.org/wiki/NTFS_symbolic_link
93+
94+
-r maxretries
95+
the maximum number of times to retry the restore command if it
96+
fails. After each failure, we wait for sleeptime * num_retries
97+
so that the wait time increases progressively, so by default
98+
we will wait 5 secs, 10 secs then 15 secs before reporting
99+
the failure back to the database server. This will be
100+
interpreted as and end of recovery and the Standby will come
101+
up fully as a result.
102+
Default=3
103+
104+
-s sleeptime
105+
the number of seconds to sleep between testing to see
106+
if the file to be restored is available in the archive yet.
107+
The default setting is not necessarily recommended,
108+
consult the main database server manual for discussion.
109+
Default=5
110+
111+
-t triggerfile
112+
the presence of the triggerfile will cause recovery to end
113+
whether or not the next file is available
114+
It is recommended that you use a structured filename to
115+
avoid confusion as to which server is being triggered
116+
when multiple servers exist on same system.
117+
e.g. /tmp/pgsql.trigger.5432
118+
119+
-w maxwaittime
120+
the maximum number of seconds to wait for the next file,
121+
after which recovery will end and the Standby will come up.
122+
The default setting is not necessarily recommended,
123+
consult the main database server manual for discussion.
124+
Default=0
125+
126+
Note: --help is not supported since pg_standby is not intended
127+
for interactive use, except during dev/test
128+
129+
o examples
130+
131+
Linux
132+
133+
archive_command = 'cp %p ../archive/%f'
134+
135+
restore_command = 'pg_standby -l -d -k 255 -r 2 -s 2 -w 0 -t /tmp/pgsql.trigger.5442 $PWD/../archive %f %p 2>> standby.log'
136+
137+
which will
138+
- use a ln command to restore WAL files from archive
139+
- produce logfile output in standby.log
140+
- keep the last 255 full WAL files, plus the current one
141+
- sleep for 2 seconds between checks for next WAL file is full
142+
- never timeout if file not found
143+
- stop waiting when a trigger file called /tmp.pgsql.trigger.5442 appears
144+
145+
Windows
146+
147+
archive_command = 'copy %p ..\\archive\\%f'
148+
Note that backslashes need to be doubled in the archive_command, but
149+
*not* in the restore_command, in 8.2, 8.1, 8.0 on Windows.
150+
151+
restore_command = 'pg_standby -c -d -s 5 -w 0 -t C:\pgsql.trigger.5442
152+
..\archive %f %p 2>> standby.log'
153+
154+
which will
155+
- use a copy command to restore WAL files from archive
156+
- produce logfile output in standby.log
157+
- sleep for 5 seconds between checks for next WAL file is full
158+
- never timeout if file not found
159+
- stop waiting when a trigger file called C:\pgsql.trigger.5442 appears
160+
161+
o reported test success
162+
163+
SUSE Linux 10.2
164+
Windows XP Pro

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp