Imported upstream version 1.5
[manpages-zh.git] / raw / man1 / pg_ctl.1
blob2b78e2d019bbb89a28cd8e579211d7dacf18bb54
1 .\\" auto-generated by docbook2man-spec $Revision: 1.1 $
2 .TH "PG_CTL" "1" "2003-11-02" "Application" "PostgreSQL Server Applications"
3 .SH NAME
4 pg_ctl \- start, stop, or restart a PostgreSQL server
6 .SH SYNOPSIS
7 .sp
8 \fBpg_ctl\fR \fBstart\fR\fR [ \fR\fB-w \fR\fR]\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-l \fIfilename\fB \fR\fR]\fR\fR [ \fR\fB-o \fIoptions\fB \fR\fR]\fR\fR [ \fR\fB-p \fIpath\fB \fR\fR]\fR
10 \fBpg_ctl\fR \fBstop\fR\fR [ \fR\fB-W \fR\fR]\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-m \fR\fB s[mart]\fR | \fBf[ast]\fR | \fBi[mmediate]\fR\fB \fR\fR]\fR
12 \fBpg_ctl\fR \fBrestart\fR\fR [ \fR\fB-w \fR\fR]\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-m \fR\fB s[mart]\fR | \fBf[ast]\fR | \fBi[mmediate]\fR\fB \fR\fR]\fR\fR [ \fR\fB-o \fIoptions\fB \fR\fR]\fR
14 \fBpg_ctl\fR \fBreload\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR
16 \fBpg_ctl\fR \fBstatus\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR
17 .SH "DESCRIPTION"
18 .PP
19 \fBpg_ctl\fR is a utility for starting,
20 stopping, or restarting the PostgreSQL
21 backend server (\fBpostmaster\fR(1)), or displaying the
22 status of a running server. Although the server can be started
23 manually, \fBpg_ctl\fR encapsulates tasks such
24 as redirecting log output and properly detaching from the terminal
25 and process group. It also provides convenient options for
26 controlled shutdown.
27 .PP
28 In \fBstart\fR mode, a new server is launched. The
29 server is started in the background, and standard input is attached to
30 \fI/dev/null\fR. The standard output and standard
31 error are either appended to a log file (if the \fB-l\fR
32 option is used), or redirected to \fBpg_ctl\fR's 
33 standard output (not standard error). If no log file is chosen, the 
34 standard output of \fBpg_ctl\fR should be redirected 
35 to a file or piped to another process, for example a log rotating program,
36 otherwise \fBpostmaster\fR will write its output to the controlling
37 terminal (from the background) and will not leave the shell's
38 process group.
39 .PP
40 In \fBstop\fR mode, the server that is running in
41 the specified data directory is shut down. Three different
42 shutdown methods can be selected with the \fB-m\fR
43 option: ``Smart'' mode waits for all the clients to
44 disconnect. This is the default. ``Fast'' mode does
45 not wait for clients to disconnect. All active transactions are
46 rolled back and clients are forcibly disconnected, then the
47 server is shut down. ``Immediate'' mode will abort
48 all server processes without a clean shutdown. This will lead to 
49 a recovery run on restart.
50 .PP
51 \fBrestart\fR mode effectively executes a stop followed
52 by a start. This allows changing the \fBpostmaster\fR
53 command-line options.
54 .PP
55 \fBreload\fR mode simply sends the
56 \fBpostmaster\fR process a \fBSIGHUP\fR
57 signal, causing it to reread its configuration files
58 (\fIpostgresql.conf\fR,
59 \fIpg_hba.conf\fR, etc.). This allows changing of
60 configuration-file options that do not require a complete restart
61 to take effect.
62 .PP
63 \fBstatus\fR mode checks whether a server is running in
64 the specified data directory. If it is, the PID
65 and the command line options that were used to invoke it are
66 displayed.
67 .SH "OPTIONS"
68 .PP
69 .TP
70 \fB-D \fIdatadir\fB\fR
71 Specifies the file system location of the database files. If
72 this is omitted, the environment variable
73 \fBPGDATA\fR is used.
74 .TP
75 \fB-l \fIfilename\fB\fR
76 Append the server log output to
77 \fIfilename\fR. If the file does not
78 exist, it is created. The \fBumask\fR is set to 077, so access to
79 the log file from other users is disallowed by default.
80 .TP
81 \fB-m \fImode\fB\fR
82 Specifies the shutdown mode. \fImode\fR
83 may be smart, fast, or
84 immediate, or the first letter of one of
85 these three.
86 .TP
87 \fB-o \fIoptions\fB\fR
88 Specifies options to be passed directly to the
89 \fBpostmaster\fR command.
91 The options are usually surrounded by single or double
92 quotes to ensure that they are passed through as a group.
93 .TP
94 \fB-p \fIpath\fB\fR
95 Specifies the location of the \fIpostmaster\fR
96 executable. By default the \fIpostmaster\fR executable is taken from the same
97 directory as \fBpg_ctl\fR, or failing that, the hard-wired
98 installation directory. It is not necessary to use this
99 option unless you are doing something unusual and get errors
100 that the \fIpostmaster\fR executable was not found.
102 \fB-s\fR
103 Only print errors, no informational messages.
105 \fB-w\fR
106 Wait for the start or shutdown to complete. Times out after
107 60 seconds. This is the default for shutdowns. A successful 
108 shutdown is indicated by removal of the PID 
109 file. For starting up, a successful \fBpsql -l\fR 
110 indicates success. \fBpg_ctl\fR will attempt to 
111 use the proper port for \fBpsql\fR. If the environment variable 
112 \fBPGPORT\fR exists, that is used. Otherwise, it will see if a port 
113 has been set in the \fIpostgresql.conf\fR file. 
114 If neither of those is used, it will use the default port that 
115 PostgreSQL was compiled with 
116 (5432 by default).
118 \fB-W\fR
119 Do not wait for start or shutdown to complete. This is the
120 default for starts and restarts.
122 .SH "ENVIRONMENT"
124 \fBPGDATA\fR
125 Default data directory location.
127 \fBPGPORT\fR
128 Default port for \fBpsql\fR(1) (used by the -w option).
130 For others, see \fBpostmaster\fR(1).
132 .SH "FILES"
134 \fB\fIpostmaster.pid\fB\fR
135 The existence of this file in the data directory is used to help
136 \fBpg_ctl\fR determine if the server is
137 currently running or not.
139 \fB\fIpostmaster.opts.default\fB\fR
140 If this file exists in the data directory,
141 \fBpg_ctl\fR (in \fBstart\fR
142 mode) will pass the contents of the file as options to the
143 \fBpostmaster\fR command, unless overridden by the
144 \fB-o\fR option.
146 \fB\fIpostmaster.opts\fB\fR
147 If this file exists in the data directory,
148 \fBpg_ctl\fR (in \fBrestart\fR mode) 
149 will pass the contents of the file as options to the 
150 \fBpostmaster\fR, unless overridden 
151 by the \fB-o\fR option. The contents of this file 
152 are also displayed in \fBstatus\fR mode.
154 \fB\fIpostgresql.conf\fB\fR
155 This file, located in the data directory, is parsed to find the
156 proper port to use with \fBpsql\fR when the
157 \fB-w\fR is given in \fBstart\fR mode.
158 .SH "NOTES"
160 Waiting for complete start is not a well-defined operation and may
161 fail if access control is set up so that a local client cannot
162 connect without manual interaction (e.g., password authentication).
163 .SH "EXAMPLES"
164 .SS "STARTING THE SERVER"
166 To start up a server:
169 $ \fBpg_ctl start\fR
173 An example of starting the server, blocking until the server has
174 come up is:
177 $ \fBpg_ctl -w start\fR
181 For a server using port 5433, and
182 running without \fBfsync\fR, use:
185 $ \fBpg_ctl -o "-F -p 5433" start\fR
188 .SS "STOPPING THE SERVER"
192 $ \fBpg_ctl stop\fR
195 stops the server. Using the \fB-m\fR switch allows one
196 to control \fBhow\fR the backend shuts down.
197 .SS "RESTARTING THE SERVER"
199 Restarting the server is almost equivalent to stopping the
200 server and starting it again
201 except that \fBpg_ctl\fR saves and reuses the command line options that
202 were passed to the previously running instance. To restart
203 the server in the simplest form, use:
206 $ \fBpg_ctl restart\fR
210 To restart server,
211 waiting for it to shut down and to come up:
214 $ \fBpg_ctl -w restart\fR
218 To restart using port 5433 and disabling \fBfsync\fR after restarting:
221 $ \fBpg_ctl -o "-F -p 5433" restart\fR
224 .SS "SHOWING THE SERVER STATUS"
226 Here is a sample status output from
227 \fBpg_ctl\fR:
230 $ \fBpg_ctl status\fR
231 pg_ctl: postmaster is running (pid: 13718)
232 Command line was:
233 /usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'
236 This is the command line that would be invoked in restart mode.
237 .SH "SEE ALSO"
239 \fBpostmaster\fR(1)