Skip to content

Commit d2511d7

Browse files
committed
Doc: mention packager-supplied tools for server start/stop, initdb, etc.
The majority of our audience is probably using a pre-packaged Postgres build rather than raw sources. For them, much of runtime.sgml is not too relevant, and they should be reading the packager's docs instead. Add some notes pointing that way in appropriate places. Text by me; thanks to Daniel Gustafsson for review and discussion, and to Laurenz Albe for an earlier version. Discussion: https://postgr.es/m/[email protected]
1 parent 5ccf322 commit d2511d7

File tree

1 file changed

+79
-16
lines changed

1 file changed

+79
-16
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@
44
<title>Server Setup and Operation</title>
55

66
<para>
7-
This chapter discusses how to set up and run the database server
7+
This chapter discusses how to set up and run the database server,
88
and its interactions with the operating system.
99
</para>
1010

11+
<para>
12+
The directions in this chapter assume that you are working with
13+
plain <productname>PostgreSQL</productname> without any additional
14+
infrastructure, for example a copy that you built from source
15+
according to the directions in the preceding chapters.
16+
If you are working with a pre-packaged or vendor-supplied
17+
version of <productname>PostgreSQL</productname>, it is likely that
18+
the packager has made special provisions for installing and starting
19+
the database server according to your system's conventions.
20+
Consult the package-level documentation for details.
21+
</para>
22+
1123
<sect1 id="postgres-user">
1224
<title>The <productname>PostgreSQL</productname> User Account</title>
1325

@@ -21,9 +33,15 @@
2133
separate user account. This user account should only own the data
2234
that is managed by the server, and should not be shared with other
2335
daemons. (For example, using the user <literal>nobody</literal> is a bad
24-
idea.) It is not advisable to install executables owned by this
25-
user because compromised systems could then modify their own
26-
binaries.
36+
idea.) In particular, it is advisable that this user account not own
37+
the <productname>PostgreSQL</productname> executable files, to ensure
38+
that a compromised server process could not modify those executables.
39+
</para>
40+
41+
<para>
42+
Pre-packaged versions of <productname>PostgreSQL</productname> will
43+
typically create a suitable user account automatically during
44+
package installation.
2745
</para>
2846

2947
<para>
@@ -71,11 +89,26 @@
7189
completely up to you where you choose to store your data. There is no
7290
default, although locations such as
7391
<filename>/usr/local/pgsql/data</filename> or
74-
<filename>/var/lib/pgsql/data</filename> are popular. To initialize a
75-
database cluster, use the command <xref
76-
linkend="app-initdb"/>,<indexterm><primary>initdb</primary></indexterm> which is
77-
installed with <productname>PostgreSQL</productname>. The desired
78-
file system location of your database cluster is indicated by the
92+
<filename>/var/lib/pgsql/data</filename> are popular.
93+
The data directory must be initialized before being used, using the program
94+
<xref linkend="app-initdb"/><indexterm><primary>initdb</primary></indexterm>
95+
which is installed with <productname>PostgreSQL</productname>.
96+
</para>
97+
98+
<para>
99+
If you are using a pre-packaged version
100+
of <productname>PostgreSQL</productname>, it may well have a specific
101+
convention for where to place the data directory, and it may also
102+
provide a script for creating the data directory. In that case you
103+
should use that script in preference to
104+
running <command>initdb</command> directly.
105+
Consult the package-level documentation for details.
106+
</para>
107+
108+
<para>
109+
To initialize a database cluster manually,
110+
run <command>initdb</command> and specify the desired
111+
file system location of the database cluster with the
79112
<option>-D</option> option, for example:
80113
<screen>
81114
<prompt>$</prompt> <userinput>initdb -D /usr/local/pgsql/data</userinput>
@@ -309,10 +342,22 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput>
309342
Before anyone can access the database, you must start the database
310343
server. The database server program is called
311344
<command>postgres</command>.<indexterm><primary>postgres</primary></indexterm>
312-
The <command>postgres</command> program must know where to
313-
find the data it is supposed to use. This is done with the
314-
<option>-D</option> option. Thus, the simplest way to start the
315-
server is:
345+
</para>
346+
347+
<para>
348+
If you are using a pre-packaged version
349+
of <productname>PostgreSQL</productname>, it almost certainly includes
350+
provisions for running the server as a background task according to the
351+
conventions of your operating system. Using the package's
352+
infrastructure to start the server will be much less work than figuring
353+
out how to do this yourself. Consult the package-level documentation
354+
for details.
355+
</para>
356+
357+
<para>
358+
The bare-bones way to start the server manually is just to invoke
359+
<command>postgres</command> directly, specifying the location of the
360+
data directory with the <option>-D</option> option, for example:
316361
<screen>
317362
$ <userinput>postgres -D /usr/local/pgsql/data</userinput>
318363
</screen>
@@ -364,7 +409,7 @@ pg_ctl start -l logfile
364409
<secondary>starting the server during</secondary>
365410
</indexterm>
366411
Autostart scripts are operating-system-specific.
367-
There are a few distributed with
412+
There are a few example scripts distributed with
368413
<productname>PostgreSQL</productname> in the
369414
<filename>contrib/start-scripts</filename> directory. Installing one will require
370415
root privileges.
@@ -1481,9 +1526,23 @@ $ <userinput>cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages</userinp
14811526
</indexterm>
14821527

14831528
<para>
1484-
There are several ways to shut down the database server. You control
1485-
the type of shutdown by sending different signals to the supervisor
1529+
There are several ways to shut down the database server.
1530+
Under the hood, they all reduce to sending a signal to the supervisor
14861531
<command>postgres</command> process.
1532+
</para>
1533+
1534+
<para>
1535+
If you are using a pre-packaged version
1536+
of <productname>PostgreSQL</productname>, and you used its provisions
1537+
for starting the server, then you should also use its provisions for
1538+
stopping the server. Consult the package-level documentation for
1539+
details.
1540+
</para>
1541+
1542+
<para>
1543+
When managing the server directly, you can control the type of shutdown
1544+
by sending different signals to the <command>postgres</command>
1545+
process:
14871546

14881547
<variablelist>
14891548
<varlistentry>
@@ -1620,6 +1679,10 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
16201679
is to dump and reload the database, though this can be slow. A
16211680
faster method is <xref linkend="pgupgrade"/>. Replication methods are
16221681
also available, as discussed below.
1682+
(If you are using a pre-packaged version
1683+
of <productname>PostgreSQL</productname>, it may provide scripts to
1684+
assist with major version upgrades. Consult the package-level
1685+
documentation for details.)
16231686
</para>
16241687

16251688
<para>

0 commit comments

Comments
 (0)