1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.49 2001/02/09 20:38:15 petere Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.50 2001/02/10 00:50:18 petere Exp $
3
3
-->
4
4
5
5
<Chapter Id="runtime">
@@ -164,6 +164,20 @@ NOTICE: Initializing database with en_US collation order.
164
164
must also specify the <option>-i</option> option.
165
165
</para>
166
166
167
+ <para>
168
+ This shells syntax can get tedious quickly. Therefore the shell
169
+ script wrapper <application>pg_ctl</application> is provided that
170
+ encapsulates some of the tasks. E.g.,
171
+ <programlisting>
172
+ pg_ctl start -l logfile
173
+ </programlisting>
174
+ will start the server in the background and put the output into the
175
+ named log file. The <option>-D</option> option has the same
176
+ meaning as when invoking postmaster directly.
177
+ <application>pg_ctl</application> also implements a symmetric
178
+ <quote>stop</quote> operation.
179
+ </para>
180
+
167
181
<para>
168
182
Normally, you will want to start the database server when the
169
183
computer boots up. This is not required; the
@@ -178,67 +192,78 @@ NOTICE: Initializing database with en_US collation order.
178
192
with them. Many systems have a file
179
193
<filename>/etc/rc.local</filename> or
180
194
<filename>/etc/rc.d/rc.local</filename> which is almost certainly
181
- no bad place to put such a command. Whatever you do, postmaster
195
+ no bad place to put such a command. Whatever you do, the server
182
196
must be run by the <productname>Postgres</productname> user account
183
197
<emphasis>and not by root</emphasis> or any other user. Therefore
184
198
you probably always want to form your command lines along the lines
185
199
of <literal>su -c '...' postgres</literal>, for example:
186
200
<programlisting>
187
- nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1 ' postgres &
201
+ su -c 'pg_ctl -D /usr/local/pgsql/data -l serverlog ' postgres
188
202
</programlisting>
189
- (using the program <application>nohup</application> to prevent the
190
- server from dying when you log out).
191
203
</para>
192
204
193
205
<para>
194
- Here are a few more operating system specific suggestions.
206
+ Here are a few more operating system specific suggestions. (Always
207
+ replace the proper installation directory and the user name you
208
+ chose.)
195
209
196
210
<itemizedlist>
197
211
<listitem>
198
212
<para>
199
- Edit the file <filename>rc.local</filename> on
200
- <productname>NetBSD</productname> or file
201
- <filename>rc2.d</filename> on <productname>Solaris</productname> to contain the
202
- following single line:
213
+ For <productname>FreeBSD</productname>, take a look at the file
214
+ <filename>contrib/start-scripts/freebsd</filename> in the
215
+ <productname>PostgreSQL</productname> source distribution.
216
+ </para>
217
+ </listitem>
218
+
219
+ <listitem>
220
+ <para>
221
+ On <productname>OpenBSD</productname>, add the following lines
222
+ to the file <filename>/etc/rc.local</filename>:
203
223
<programlisting>
204
- su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data"
224
+ if [ -x /usr/local/pgsql/bin/pg_ctl -a -x /usr/local/pgsql/bin/postmaster ]; then
225
+ su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log -s' postgres
226
+ echo -n ' postgresql'
227
+ fi
205
228
</programlisting>
206
229
</para>
207
230
</listitem>
208
231
209
232
<listitem>
210
233
<para>
211
- On <productname>FreeBSD</productname> edit
212
- <filename>/usr/local/etc/rc.d/pgsql.sh</filename> to contain the
213
- following lines and make it <literal>chmod 755</literal> and
214
- <literal>chown root:bin</literal>.
234
+ On <productname>Linux</productname> systems either add
215
235
<programlisting>
216
- #!/bin/sh
217
- [ -x /usr/local/pgsql/bin/postmaster ] && {
218
- su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
219
- -D/usr/local/pgsql/data
220
- -S -o -F > /usr/local/pgsql/errlog' &
221
- echo -n ' pgsql'
222
- }
236
+ /usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data
223
237
</programlisting>
224
- You may put the line breaks as shown above. The shell is smart
225
- enough to keep parsing beyond end-of-line if there is an
226
- expression unfinished. The exec saves one layer of shell under
227
- the postmaster process so the parent is init .
238
+ to <filename>/etc/rc.d/rc.local</filename> or look into the file
239
+ <filename>contrib/start-scripts/linux</filename> in the
240
+ <productname>PostgreSQL</productname> source distribution to
241
+ integrate the start and shutdown into the run level system .
228
242
</para>
229
243
</listitem>
230
244
231
245
<listitem>
232
246
<para>
233
- On <productname>RedHat Linux</productname> add a file
234
- <filename>/etc/rc.d/init.d/postgres.init</filename>
235
- which is based on the example in <filename>contrib/linux/</filename>.
236
- Then make a softlink to this file from
237
- <filename>/etc/rc.d/rc5.d/S98postgres.init</filename>.
238
- </para>
239
- </listitem>
240
- </itemizedlist>
241
- </para>
247
+ On <productname>NetBSD</productname>, either use the
248
+ <productname>FreeBSD</productname> or
249
+ <productname>Linux</productname> start scripts, depending on
250
+ preference, as an example and place the file at
251
+ <filename>/usr/local/etc/rc.d/postgresql</filename>.
252
+ </para>
253
+ </listitem>
254
+
255
+ <listitem>
256
+ <para>
257
+ On <productname>Solaris</productname>, edit the file
258
+ <filename>rc2.d</filename> to contain the following single line:
259
+ <programlisting>
260
+ su - postgres -c "/usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data"
261
+ </programlisting>
262
+ </para>
263
+ </listitem>
264
+ </itemizedlist>
265
+
266
+ </para>
242
267
243
268
<para>
244
269
While the <application>postmaster</application> is running, it's
@@ -248,13 +273,6 @@ su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data"
248
273
shutting down the postmaster.
249
274
</para>
250
275
251
- <para>
252
- The shell script wrapper <application>pg_ctl</application> that
253
- comes with <productname>Postgres</productname> can also be used to
254
- control starting (and stopping!) of the database server in
255
- intelligent fashion.
256
- </para>
257
-
258
276
<sect2 id="postmaster-start-failures">
259
277
<title>Server Start-up Failures</title>
260
278
0 commit comments