1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00

Update and polish postmaster and postgres help output and man pages.

This commit is contained in:
Peter Eisentraut
2000-11-14 18:11:32 +00:00
parent 3eaf3363d7
commit 8a9315ca92
5 changed files with 596 additions and 669 deletions

View File

@@ -1,88 +1,256 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/postmaster.sgml,v 1.14 2000/11/13 23:57:20 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/postmaster.sgml,v 1.15 2000/11/14 18:11:31 petere Exp $
Postgres documentation
-->
<refentry id="APP-POSTMASTER">
<docinfo>
<date>2000-11-12</date>
</docinfo>
<refmeta>
<refentrytitle id="APP-POSTMASTER-TITLE">
<application>postmaster</application>
</refentrytitle>
<refentrytitle id="APP-POSTMASTER-TITLE"><application>postmaster</application></refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname id="postmaster-ref">
<application>postmaster</application>
</refname>
<refpurpose>
Run the <productname>Postgres</productname> multi-user backend
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1999-07-20</date>
</refsynopsisdivinfo>
<synopsis>
postmaster [ -B <replaceable class="parameter">nBuffers</replaceable> ] [ -D <replaceable class="parameter">DataDir</replaceable> ] [ -N <replaceable class="parameter">maxBackends</replaceable> ] [ -S ]
[ -d <replaceable class="parameter">DebugLevel</replaceable> ]
[ -h <replaceable class="parameter">hostname</replaceable> ] [ -i ]
[ -k <replaceable class="parameter">path</replaceable> ] [ -l ]
[ -o <replaceable class="parameter">BackendOptions</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] [ -n | -s ]
</synopsis>
<refsect2 id="R2-APP-POSTMASTER-1">
<refsect2info>
<date>1999-05-19</date>
</refsect2info>
<title>
Inputs
</title>
<refnamediv>
<refname id="postmaster-ref">postmaster</refname>
<refpurpose><productname>PostgreSQL</productname> multi-user database server</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>postmaster</command>
<arg>-A <group choice="plain"><arg>0</arg><arg>1</arg></group></arg>
<arg>-B <replaceable>nbuffers</replaceable></arg>
<arg>-c <replaceable>name</replaceable>=<replaceable>value</replaceable></arg>
<arg>-d <replaceable>debug-level</replaceable></arg>
<arg>-D <replaceable>datadir</replaceable></arg>
<arg>-F</arg>
<arg>-h <replaceable>hostname</replaceable></arg>
<arg>-i</arg>
<arg>-k <replaceable>filename</replaceable></arg>
<arg>-l</arg>
<arg>-N <replaceable>max-connections</replaceable></arg>
<arg>-o <replaceable>extra-options</replaceable></arg>
<arg>-p <replaceable>port</replaceable></arg>
<arg>-S</arg>
<group><arg>-n</arg><arg>-s</arg></group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<application>postmaster</application> is the
<productname>PostgreSQL</productname> multi-user database server.
In order for a client application to access a database it connects
(over a network or locally) to a running
<application>postmaster</application>. The
<application>postmaster</application> then starts a separate server
process (<quote><xref linkend="app-postgres"
endterm="app-postgres-title"></quote>) to handle the connection.
The postmaster also manages the communication among server
processes.
</para>
<para>
By default the postmaster starts in the foreground and prints log
messages to the standard output. In practical applications the
postmaster should be started as a background process, perhaps at
boot time.
</para>
<para>
One postmaster always manages the data from exactly one database
cluster. A database cluster is a collection of databases that is
stored at a common file system location. When the postmaster
starts it needs to know the location of the database cluster files
(<quote>data area</quote>). This is done with the
<option>-D</option> invocation option or the <envar>PGDATA</envar>
environment variable, there is no default. More than one
postmaster process can run on a system at one time, as long as they
use different data areas and different port numbers (see below). A
data area is created with <xref linkend="app-initdb"
endterm="app-initdb-title">.
</para>
<refsect2 id="app-postmaster-options">
<title>Options</title>
<para>
<application>postmaster</application> accepts the following command line arguments:
<application>postmaster</application> accepts the following
command line arguments. For a detailed discussion of the options
consult the <citetitle>Administrator's Guide</citetitle>. You can
also save typing most of these options by setting up a
configuration file.
<variablelist>
<varlistentry>
<term>-B <replaceable class="parameter">nBuffers</replaceable></term>
<term>-A 0|1</term>
<listitem>
<para>
Sets the number of shared-memory disk buffers for the
<application>postmaster</application>
to allocate for use by the backend server processes that it
starts. This value defaults to 64 buffers, where each buffer is 8k bytes
(or whatever BLCKSZ is set to in src/include/config.h).
Enables run-time assert checks, which is a debugging aid to
detect programming mistakes. This is only available if it was
enabled during compilation. If so, the default is on.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-D <replaceable class="parameter">DataDir</replaceable></term>
<term>-B <replaceable class="parameter">nbuffers</replaceable></term>
<listitem>
<para>
Specifies the directory to use as the root of the tree of database
directories. If -D is not given, the default data directory name is
the value of the environment variable
<envar>PGDATA</envar>.
If <envar>PGDATA</envar> is not set, then the directory used is
<filename>$POSTGRESHOME/data</filename>.
If neither environment variable is set and this command-line
option is not specified, the default directory that was
set at compile-time is used.
Sets the number of shared buffers for use by the server
processes. This value defaults to 64 buffers, where each
buffer is 8 kB.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-N <replaceable class="parameter">maxBackends</replaceable></term>
<term>-c <replaceable>name</replaceable>=<replaceable>value</replaceable></term>
<listitem>
<para>
Sets the maximum number of backend server processes that this postmaster
is allowed to start. By default, this value is 32, but it can be set
as high as 1024 if your system will support that many processes.
(Note that -B is required to be at least twice -N, so you'll need to
increase -B if you increase -N.)
Both the default and upper limit values for -N can be altered
when building <productname>Postgres</productname>
(see src/include/config.h).
Sets a named run-time parameter. Consult the
<citetitle>Administrator's Guide</citetitle> for a list and
descriptions. Most of the other command line options are in
fact short forms of such a parameter assignment.
</para>
<para>
On some systems it is also possible to equivalently use
GNU-style long options in the form
<literal>--name=value</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-d <replaceable>debug-level</replaceable></term>
<listitem>
<para>
Sets the debug level. The higher this value is set, the more
debugging output is written to the server log. The default is
0, which means no debugging. Values up to 4 make sense.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-D <replaceable class="parameter">datadir</replaceable></term>
<listitem>
<para>
Specifies the file system location of the data directory. See
discussion above.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-F</term>
<listitem>
<para>
Disables <function>fsync</function> calls for performance
improvement at the risk of data corruption. Read the detailed
documentation before using this!
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-h <replaceable class="parameter">hostname</replaceable></term>
<listitem>
<para>
Specifies the TCP/IP hostname or address on which the
<application>postmaster</application> is to listen for
connections from client applications. Defaults to the value
of the <envar>PGHOST</envar> environment variable, or if
<envar>PGHOST</envar> is not set, it defaults to listening on
all configured addresses (including localhost).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-i</term>
<listitem>
<para>
Allows clients to connect via TCP/IP (Internet domain)
connections. Without this option, only local Unix domain
socket connections are accepted.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-k <replaceable class="parameter">filename</replaceable></term>
<listitem>
<para>
Specifies the Unix domain socket file name on which the
<application>postmaster</application> is to listen for
connections from client applications. Defaults to the value
of the <envar>PGUNIXSOCKET</envar> environment variable, or if
<envar>PGUNIXSOCKET</envar> is not set, then defaults to a
file in <filename>/tmp</filename> constructed from the port
number.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-l</term>
<listitem>
<para>
Enables secure connections using SSL. The <option>-i</option>
option is also required. You must have compiled with SSL
enabled to use this option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-N <replaceable class="parameter">max-connections</replaceable></term>
<listitem>
<para>
Sets the maximum number of client connections that this
postmaster will accept. By default, this value is 32, but it
can be set as high as 1024 if your system will support that
many processes. (Note that <option>-B</option> is required to
be at least twice <option>-N</option>.)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-o <replaceable class="parameter">extra-options</replaceable></term>
<listitem>
<para>
The command line-style options specified in <replaceable
class="parameter">EXTRA-OPTIONS</replaceable> are passed to
all backend server processes started by this
<application>postmaster</application>. See <xref
linkend="app-postgres" endterm="app-postgres-title"> for
possibilities. If the option string contains any spaces, the
entire string must be quoted.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-p <replaceable class="parameter">port</replaceable></term>
<listitem>
<para>
Specifies the TCP/IP port or local Unix domain socket file
extension on which the <application>postmaster</application>
is to listen for connections from client applications.
Defaults to the value of the <envar>PGPORT</envar> environment
variable, or if <envar>PGPORT</envar> is not set, then
defaults to the value established during compilation (normally
5432). If you specify a port other than the default port,
then all client applications must specify the same port using
either command-line options or <envar>PGPORT</envar>.
</para>
</listitem>
</varlistentry>
@@ -92,171 +260,36 @@ postmaster [ -B <replaceable class="parameter">nBuffers</replaceable> ] [ -D <re
<listitem>
<para>
Specifies that the <application>postmaster</application>
process should start up in silent mode. That is, it will disassociate
from the user's (controlling) tty, start its own process group, and
redirect its standard output and standard error to
<filename>/dev/null</filename>.
process should start up in silent mode. That is, it will
disassociate from the user's (controlling) terminal, start its
own process group, and redirect its standard output and
standard error to <filename>/dev/null</filename>.
</para>
<para>
<emphasis>Note</emphasis> that using this switch makes it very
difficult to troubleshoot problems, since all tracing and logging
output that would normally be generated by this postmaster and its
child backends will be discarded.
Using this switch discards all logging output, which is
probably not what you want, since it makes it very difficult
to troubleshoot problems. See below for a better way to start
the postmaster in the background.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-d <replaceable class="parameter">DebugLevel</replaceable></term>
<listitem>
<para>
Determines the amount of debugging output the backend servers will
produce.
If <replaceable class="parameter">DebugLevel</replaceable>
is one, the postmaster will trace all connection traffic.
Levels two and higher turn on increasing amounts of debug output
from the backend processes, and the postmaster
displays more information
including the backend environment and process traffic.
Note that unless the postmaster's standard output and standard error
are redirected into a log file, all this output will appear on the
controlling tty of the <application>postmaster</application>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-h <replaceable class="parameter">hostName</replaceable></term>
<listitem>
<para>
Specifies the TCP/IP hostname or address
on which the <application>postmaster</application>
is to listen for connections from frontend applications. Defaults to
the value of the <envar>PGHOST</envar>
environment variable, or if <envar>PGHOST</envar>
is not set, it defaults to listening on all configured addresses
(including localhost).
</para>
<para>
If you use a hostname do not try to run
multiple instances of <application>postmaster</application> on the
same IP address but different ports. Doing so will result in them
attempting (incorrectly) to use the same shared memory segments.
Also, if you use a hostname, all of the host's IP addresses
on which <application>postmaster</application> instances are
listening must be distinct in the two last octets.
</para>
<para>
If you don't use this option, each instance must listen on a
different port (via -p or <envar>PGPORT</envar>). And, of course, do
not try to use both approaches on one host.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-i</term>
<listitem>
<para>
Allows clients to connect via TCP/IP (Internet domain) connections.
Without this option, only local Unix domain socket connections are
accepted.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-k <replaceable class="parameter">path</replaceable></term>
<listitem>
<para>
Specifies the local Unix domain socket path name
on which the <application>postmaster</application>
is to listen for connections from frontend applications. Defaults to
the value of the
<envar>PGUNIXSOCKET</envar>
environment variable, or if <envar>PGUNIXSOCKET</envar>
is not set, then defaults to a file in <filename>/tmp</filename>
constructed from the port number.
</para>
<para>
You can use this option to put the Unix-domain socket in a
directory that is private to one or more users using Unix
directory permissions. This is necessary for securely
creating databases automatically on shared machines.
In that situation, also disallow all TCP/IP connections
initially in <filename>pg_hba.conf</filename>.
If you specify a socket path other than the
default then all frontend applications (including
<application>psql</application>) must specify the same
socket path using either command-line options or
<envar>PGUNIXSOCKET</envar>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-l</term>
<listitem>
<para>
Enables secure connections using SSL. The <option>-i</option> option
is also required.
You must have compiled with SSL enabled to use this option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-o <replaceable class="parameter">BackendOptions</replaceable></term>
<listitem>
<para>
The
<literal>postgres</literal>
option(s) specified in
<replaceable class="parameter">BackendOptions</replaceable>
are passed to all backend server processes started by this
<application>postmaster</application>.
If the option string contains any spaces, the entire string must be
quoted.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-p <replaceable class="parameter">port</replaceable></term>
<listitem>
<para>
Specifies the TCP/IP port or local Unix domain socket file extension
on which the <application>postmaster</application>
is to listen for connections from frontend applications. Defaults to
the value of the
<envar>PGPORT</envar>
environment variable, or if <envar>PGPORT</envar>
is not set, then defaults to the value established when Postgres was
compiled (normally 5432). If you specify a port other than the
default port, then all frontend applications (including
<application>psql</application>) must specify the same
port using either command-line options or
<envar>PGPORT</envar>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
Two additional command line options are available for debugging problems
that cause a backend to die abnormally.
These options control the behavior of the
<application>postmaster</application> in this situation, and
<emphasis>neither option is intended for use in
ordinary operation</emphasis>.
Two additional command line options are available for debugging
problems that cause a backend to die abnormally. These options
control the behavior of the <application>postmaster</application>
in this situation, and <emphasis>neither option is intended for
use in ordinary operation</emphasis>.
</para>
<para>
The ordinary strategy for this situation is to notify all other
backends that they must terminate and then reinitialize the shared
memory and semaphores. This is because an errant backend could have
corrupted some shared state before terminating.
memory and semaphores. This is because an errant backend could
have corrupted some shared state before terminating.
</para>
<para>
@@ -292,31 +325,12 @@ postmaster [ -B <replaceable class="parameter">nBuffers</replaceable> ] [ -D <re
</refsect2>
<refsect2 id="R2-APP-POSTMASTER-2">
<refsect2info>
<date>1999-05-19</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<variablelist>
<!--
<varlistentry>
<term>
FindBackend: could not find a backend to execute...
</term>
<listitem>
<para>
If you see this message, you do not have the
<application>postgres</application>
executable in your path. Add the directory in which
<application>postgres</application> resides to
your path.
</para>
</listitem>
</varlistentry>
-->
<varlistentry>
<term><computeroutput>
semget: No space left on device
@@ -416,124 +430,65 @@ IpcMemoryAttach: shmat() failed: Permission denied
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-APP-POSTMASTER-1">
<refsect1info>
<date>1999-05-19</date>
</refsect1info>
<title>
Description
</title>
<para>
<application>postmaster</application>
manages the communication between frontend and backend processes, as
well as allocating the shared buffer pool and SysV semaphores
(on machines without a test-and-set instruction).
<application>postmaster</application>
does not itself interact with the user and should be started as a
background process.
</para>
<para>
<emphasis>Only one postmaster should be running at a time in a given
<productname>Postgres</productname> installation.</emphasis>
Here, an installation means a database directory and
<application>postmaster</application> port number.
You can run more than one postmaster on a machine only if each one has a
separate directory and port number.
</para>
</refsect1>
<refsect1 id="R1-APP-POSTMASTER-2">
<refsect1info>
<date>1998-10-04</date>
</refsect1info>
<title>
Notes
</title>
<refsect1>
<title>Notes</title>
<para>
If at all possible,
<emphasis>do not</emphasis>
use <literal>SIGKILL</literal>
when killing the <application>postmaster</application>.
<literal>SIGHUP</literal>,
<literal>SIGINT</literal>,
or
<literal>SIGTERM</literal>
(the default signal for
<application>kill</application>(1))"
should be used instead. Using
<programlisting>
$ kill -KILL
</programlisting>
or its alternative form
<programlisting>
$ kill -9
</programlisting>
will prevent <application>postmaster</application>
from freeing the system resources (e.g., shared memory and semaphores)
that it holds before dying. Use <literal>SIGTERM</literal> instead
to avoid having to clean up manually (as described earlier).
If at all possible, <emphasis>do not</emphasis> use
<literal>SIGKILL</literal> to kill the
<application>postmaster</application>. This will prevent
<application>postmaster</application> from freeing the system
resources (e.g., shared memory and semaphores) that it holds before
terminating.
</para>
<para>
Useful utilities for dealing with shared memory problems include
<application>ipcs(1)</application>,
<application>ipcrm(1</application>), and
<application>ipcclean(1)</application>.
To terminate the postmaster normally, the signals
<literal>SIGTERM</literal>, <literal>SIGINT</literal>, or
<literal>SIGQUIT</literal> can be used. The first will wait for
all clients to terminate before quitting, the second will
forcefully disconnect all clients, and the third will quit
immediately without lengthy shutdown, resulting in a recovery run
during restart.
</para>
<para>
The utility command <xref linkend="app-pg-ctl"> can be used to
start and shut down the postmaster safely and comfortably.
</para>
</refsect1>
<refsect1 id="R1-APP-POSTMASTER-3">
<refsect1info>
<date>1998-10-04</date>
</refsect1info>
<title>
Usage
</title>
<refsect1 id="app-postmaster-usage">
<title>Usage</title>
<para>
To start <application>postmaster</application> using default
values, type:
To start <application>postmaster</application> in the background
using default values, type:
<programlisting>
$ nohup postmaster >logfile 2>&1 &
</programlisting>
This command will start up <application>postmaster</application>
on the default port (5432). This is the
simplest and most common way to start the
<application>postmaster</application>.
<screen>
<prompt>$</prompt> <userinput>nohup postmaster &gt;logfile 2&gt;&amp;1 &lt;/dev/null &amp;</userinput>
</screen>
</para>
<para>
To start <application>postmaster</application> with a specific port:
<programlisting>
$ nohup postmaster -p 1234 &
</programlisting>
To start <application>postmaster</application> with a specific
port:
<screen>
<prompt>$</prompt> <userinput>postmaster -p 1234</userinput>
</screen>
This command will start up <application>postmaster</application>
communicating through the port 1234. In order to
connect to this <application>postmaster</application>
using psql, you would need to run it as
<programlisting>
$ psql -p 1234
</programlisting>
communicating through the port 1234. In order to connect to this
<application>postmaster</application> using psql, you would need to
run it as
<screen>
<prompt>$</prompt> <userinput>psql -p 1234</userinput>
</screen>
or set the environment variable <envar>PGPORT</envar>:
<programlisting>
$ export PGPORT 1234
$ psql
</programlisting>
<screen>
<prompt>$</prompt> <userinput>export PGPORT=1234</userinput>
<prompt>$</prompt> <userinput>psql</userinput>
</screen>
</para>
</refsect1>
</refentry>