Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cf21985

Browse files
committed
Update section about how to start server from boot scripts.
1 parent fdf87fd commit cf21985

File tree

1 file changed

+60
-42
lines changed

1 file changed

+60
-42
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
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 $
33
-->
44

55
<Chapter Id="runtime">
@@ -164,6 +164,20 @@ NOTICE: Initializing database with en_US collation order.
164164
must also specify the <option>-i</option> option.
165165
</para>
166166

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+
167181
<para>
168182
Normally, you will want to start the database server when the
169183
computer boots up. This is not required; the
@@ -178,67 +192,78 @@ NOTICE: Initializing database with en_US collation order.
178192
with them. Many systems have a file
179193
<filename>/etc/rc.local</filename> or
180194
<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
182196
must be run by the <productname>Postgres</productname> user account
183197
<emphasis>and not by root</emphasis> or any other user. Therefore
184198
you probably always want to form your command lines along the lines
185199
of <literal>su -c '...' postgres</literal>, for example:
186200
<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
188202
</programlisting>
189-
(using the program <application>nohup</application> to prevent the
190-
server from dying when you log out).
191203
</para>
192204

193205
<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.)
195209

196210
<itemizedlist>
197211
<listitem>
198212
<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>:
203223
<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
205228
</programlisting>
206229
</para>
207230
</listitem>
208231

209232
<listitem>
210233
<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
215235
<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
223237
</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.
228242
</para>
229243
</listitem>
230244

231245
<listitem>
232246
<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>
242267

243268
<para>
244269
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"
248273
shutting down the postmaster.
249274
</para>
250275

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-
258276
<sect2 id="postmaster-start-failures">
259277
<title>Server Start-up Failures</title>
260278

0 commit comments

Comments
 (0)