Commit cdd402f8 authored by Tom Lane's avatar Tom Lane

More minor updates and copy-editing.

parent 5cfdd68f
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.68 2004/11/15 06:32:13 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.69 2004/12/26 23:06:56 tgl Exp $
--> -->
<chapter id="client-authentication"> <chapter id="client-authentication">
...@@ -53,12 +53,15 @@ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.68 2004/11/15 06:32:13 neil ...@@ -53,12 +53,15 @@ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.68 2004/11/15 06:32:13 neil
</indexterm> </indexterm>
<para> <para>
Client authentication is controlled by the file Client authentication is controlled by a configuration file,
<filename>pg_hba.conf</filename> in the data directory, e.g., which traditionally is named
<filename>/usr/local/pgsql/data/pg_hba.conf</filename>. <filename>pg_hba.conf</filename> and is stored in the database
cluster's data directory.
(<acronym>HBA</> stands for host-based authentication.) A default (<acronym>HBA</> stands for host-based authentication.) A default
<filename>pg_hba.conf</filename> file is installed when the data <filename>pg_hba.conf</filename> file is installed when the data
directory is initialized by <command>initdb</command>. directory is initialized by <command>initdb</command>. It is
possible to place the authentication configuration file elsewhere,
however; see the <xref linkend="guc-hba-file"> configuration parameter.
</para> </para>
<para> <para>
...@@ -151,8 +154,8 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -151,8 +154,8 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>hostnossl</literal></term> <term><literal>hostnossl</literal></term>
<listitem> <listitem>
<para> <para>
This record is similar to <literal>hostssl</> but with the This record type has the opposite logic to <literal>hostssl</>:
opposite logic: it only matches connection attempts made over it only matches connection attempts made over
TCP/IP that do not use <acronym>SSL</acronym>. TCP/IP that do not use <acronym>SSL</acronym>.
</para> </para>
</listitem> </listitem>
...@@ -167,7 +170,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -167,7 +170,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
The value <literal>sameuser</> specifies that the record The value <literal>sameuser</> specifies that the record
matches if the requested database has the same name as the matches if the requested database has the same name as the
requested user. The value <literal>samegroup</> specifies that requested user. The value <literal>samegroup</> specifies that
the requested user must a member of the group with the same the requested user must be a member of the group with the same
name as the requested database. Otherwise, this is the name of name as the requested database. Otherwise, this is the name of
a specific <productname>PostgreSQL</productname> database. a specific <productname>PostgreSQL</productname> database.
Multiple database names can be supplied by separating them with Multiple database names can be supplied by separating them with
...@@ -199,20 +202,23 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -199,20 +202,23 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><replaceable>CIDR-address</replaceable></term> <term><replaceable>CIDR-address</replaceable></term>
<listitem> <listitem>
<para> <para>
Specifies the client machine IP addresses that this record Specifies the client machine IP address range that this record
matches. It contains an IP address in standard dotted decimal matches. It contains an IP address in standard dotted decimal
notation and a CIDR mask length. (IP addresses can only be notation and a CIDR mask length. (IP addresses can only be
specified numerically, not as domain or host names.) For example, specified numerically, not as domain or host names.) The mask
an IPv4 CIDR mask of 8 is equivalent to an IP mask of 255.0.0.0, length indicates the number of high-order bits of the client
an IPv6 CIDR mask of 64 is equivalent to an IP mask of IP address that must match. Bits to the right of this must
ffff:ffff:ffff:ffff::. A IPv4 CIDR mask of 32 is used for single be zero in the given IP address.
hosts. There must not be any white space between the IP address, the
<literal>/</literal>, and the CIDR mask length.
</para> </para>
<para> <para>
A typical CIDR address is <literal>172.20.143.89/32</literal>. A typical <replaceable>CIDR-address</replaceable> is
There should be no white space between the IP address, the <literal>172.20.143.89/32</literal> for a single host, or
<literal>/</literal>, and the CIDR mask length. <literal>172.20.143.0/24</literal> for a network.
To specify a single host, use a CIDR mask of 32 for IPv4 or
128 for IPv6.
</para> </para>
<para> <para>
...@@ -226,7 +232,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -226,7 +232,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
</para> </para>
<para> <para>
These fields only apply to <literal>host</literal>, This field only applies to <literal>host</literal>,
<literal>hostssl</literal>, and <literal>hostnossl</> records. <literal>hostssl</literal>, and <literal>hostnossl</> records.
</para> </para>
</listitem> </listitem>
...@@ -234,20 +240,19 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -234,20 +240,19 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<varlistentry> <varlistentry>
<term><replaceable>IP-address</replaceable></term> <term><replaceable>IP-address</replaceable></term>
<term><replaceable>IP-masklen</replaceable></term> <term><replaceable>IP-mask</replaceable></term>
<listitem> <listitem>
<para> <para>
This may be used as an alternative to the These fields may be used as an alternative to the
<replaceable>CIDR-address</replaceable> notation. Instead of <replaceable>CIDR-address</replaceable> notation. Instead of
specifying the mask length, the actual mask is specified in a specifying the mask length, the actual mask is specified in a
separate column. For example, 255.0.0.0 represents a IPv4 CIDR separate column. For example, <literal>255.0.0.0</> represents an IPv4
mask length of 8, and 255.255.255.255 represents a CIDR mask CIDR mask length of 8, and <literal>255.255.255.255</> represents a
length of 32. The same matching logic is used as for a dotted CIDR mask length of 32.
notation <replaceable>IP-mask</replaceable>.
</para> </para>
<para> <para>
This field only applies to <literal>host</literal>, These fields only apply to <literal>host</literal>,
<literal>hostssl</literal>, and <literal>hostnossl</> records. <literal>hostssl</literal>, and <literal>hostnossl</> records.
</para> </para>
</listitem> </listitem>
...@@ -266,7 +271,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -266,7 +271,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>trust</></term> <term><literal>trust</></term>
<listitem> <listitem>
<para> <para>
The connection is allowed unconditionally. This method Allow the connection unconditionally. This method
allows anyone that can connect to the allows anyone that can connect to the
<productname>PostgreSQL</productname> database server to login as <productname>PostgreSQL</productname> database server to login as
any <productname>PostgreSQL</productname> user they like, any <productname>PostgreSQL</productname> user they like,
...@@ -280,7 +285,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -280,7 +285,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>reject</></term> <term><literal>reject</></term>
<listitem> <listitem>
<para> <para>
The connection is rejected unconditionally. This is useful for Reject the connection unconditionally. This is useful for
<quote>filtering out</> certain hosts from a group. <quote>filtering out</> certain hosts from a group.
</para> </para>
</listitem> </listitem>
...@@ -290,9 +295,8 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -290,9 +295,8 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>md5</></term> <term><literal>md5</></term>
<listitem> <listitem>
<para> <para>
Requires the client to supply an MD5 encrypted password for Require the client to supply an MD5-encrypted password for
authentication. This is the only method that allows encrypted authentication.
passwords to be stored in <structname>pg_shadow</structname>.
See <xref linkend="auth-password"> for details. See <xref linkend="auth-password"> for details.
</para> </para>
</listitem> </listitem>
...@@ -302,9 +306,10 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -302,9 +306,10 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>crypt</></term> <term><literal>crypt</></term>
<listitem> <listitem>
<para> <para>
Like the <literal>md5</literal> method but uses older <function>crypt()</> Require the client to supply a <function>crypt()</>-encrypted
encryption, which is needed for pre-7.2 clients. password for authentication.
<literal>md5</literal> is preferred for 7.2 and later clients. <literal>md5</literal> is preferred for 7.2 and later clients,
but pre-7.2 clients only support <literal>crypt</>.
See <xref linkend="auth-password"> for details. See <xref linkend="auth-password"> for details.
</para> </para>
</listitem> </listitem>
...@@ -314,8 +319,10 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -314,8 +319,10 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>password</></term> <term><literal>password</></term>
<listitem> <listitem>
<para> <para>
Same as <literal>md5</>, but the password is sent in clear text over the Require the client to supply an unencrypted password for
network. This should not be used on untrusted networks. authentication.
Since the password is sent in clear text over the
network, this should not be used on untrusted networks.
See <xref linkend="auth-password"> for details. See <xref linkend="auth-password"> for details.
</para> </para>
</listitem> </listitem>
...@@ -325,7 +332,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -325,7 +332,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>krb4</></term> <term><literal>krb4</></term>
<listitem> <listitem>
<para> <para>
Kerberos V4 is used to authenticate the user. This is only Use Kerberos V4 to authenticate the user. This is only
available for TCP/IP connections. See <xref available for TCP/IP connections. See <xref
linkend="kerberos-auth"> for details. linkend="kerberos-auth"> for details.
</para> </para>
...@@ -336,7 +343,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -336,7 +343,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<term><literal>krb5</></term> <term><literal>krb5</></term>
<listitem> <listitem>
<para> <para>
Kerberos V5 is used to authenticate the user. This is only Use Kerberos V5 to authenticate the user. This is only
available for TCP/IP connections. See <xref available for TCP/IP connections. See <xref
linkend="kerberos-auth"> for details. linkend="kerberos-auth"> for details.
</para> </para>
...@@ -353,30 +360,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -353,30 +360,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
operating system) and check if the user is allowed to operating system) and check if the user is allowed to
connect as the requested database user by consulting the map connect as the requested database user by consulting the map
specified after the <literal>ident</literal> key word. specified after the <literal>ident</literal> key word.
</para> See <xref linkend="auth-ident"> for details.
<para>
If you use the map <literal>sameuser</literal>, the user
names are required to be identical. If not, the map name is
looked up in the file <filename>pg_ident.conf</filename>
in the same directory as <filename>pg_hba.conf</filename>.
The connection is accepted if that file contains an
entry for this map name with the operating-system user name
and the requested <productname>PostgreSQL</productname> user
name.
</para>
<para>
For local connections, this only works on machines that
support Unix-domain socket credentials (currently
<systemitem class=osname>Linux</>, <systemitem
class=osname>FreeBSD</>, <systemitem class=osname>NetBSD</>,
<systemitem class=osname>OpenBSD</>, and
<systemitem class=osname>BSD/OS</>).
</para>
<para>
See <xref linkend="auth-ident"> below for details.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -402,7 +386,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -402,7 +386,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
<listitem> <listitem>
<para> <para>
The meaning of this optional field depends on the chosen The meaning of this optional field depends on the chosen
authentication method and is described in the next section. authentication method. Details appear below.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -423,13 +407,6 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -423,13 +407,6 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
range of allowed client IP addresses. range of allowed client IP addresses.
</para> </para>
<important>
<para>
Do not prevent the superuser from accessing the <literal>template1</literal>
database. Various utility commands need access to <literal>template1</literal>.
</para>
</important>
<para> <para>
The <filename>pg_hba.conf</filename> file is read on start-up and when The <filename>pg_hba.conf</filename> file is read on start-up and when
the main server process (<command>postmaster</>) receives a the main server process (<command>postmaster</>) receives a
...@@ -441,13 +418,13 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> ...@@ -441,13 +418,13 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
</para> </para>
<para> <para>
An example of a <filename>pg_hba.conf</filename> file is shown in Some examples of <filename>pg_hba.conf</filename> entries are shown in
<xref linkend="example-pg-hba.conf">. See the next section for details on the <xref linkend="example-pg-hba.conf">. See the next section for details on the
different authentication methods. different authentication methods.
</para> </para>
<example id="example-pg-hba.conf"> <example id="example-pg-hba.conf">
<title>An example <filename>pg_hba.conf</filename> file</title> <title>Example <filename>pg_hba.conf</filename> entries</title>
<programlisting> <programlisting>
# Allow any user on the local system to connect to any database under # Allow any user on the local system to connect to any database under
# any user name using Unix-domain sockets (the default for local # any user name using Unix-domain sockets (the default for local
...@@ -463,7 +440,7 @@ host all all 127.0.0.1/32 trust ...@@ -463,7 +440,7 @@ host all all 127.0.0.1/32 trust
# The same as the last line but using a separate netmask column # The same as the last line but using a separate netmask column
# #
# TYPE DATABASE USER CIDR-ADDRESS METHOD # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all 127.0.0.1 255.255.255.255 trust host all all 127.0.0.1 255.255.255.255 trust
# Allow any user from any host with IP address 192.168.93.x to connect # Allow any user from any host with IP address 192.168.93.x to connect
...@@ -473,11 +450,6 @@ host all all 127.0.0.1 255.255.255.255 trust ...@@ -473,11 +450,6 @@ host all all 127.0.0.1 255.255.255.255 trust
# TYPE DATABASE USER CIDR-ADDRESS METHOD # TYPE DATABASE USER CIDR-ADDRESS METHOD
host template1 all 192.168.93.0/24 ident sameuser host template1 all 192.168.93.0/24 ident sameuser
# The same as the last line but using a separate netmask column
#
# TYPE DATABASE USER CIDR-ADDRESS METHOD
host template1 all 192.168.93.0 255.255.255.0 ident sameuser
# Allow a user from host 192.168.12.10 to connect to database # Allow a user from host 192.168.12.10 to connect to database
# "template1" if the user's password is correctly supplied. # "template1" if the user's password is correctly supplied.
# #
...@@ -486,7 +458,7 @@ host template1 all 192.168.12.10/32 md5 ...@@ -486,7 +458,7 @@ host template1 all 192.168.12.10/32 md5
# In the absence of preceding "host" lines, these two lines will # In the absence of preceding "host" lines, these two lines will
# reject all connection from 192.168.54.1 (since that entry will be # reject all connection from 192.168.54.1 (since that entry will be
# matched first), but allow Kerberos V connections from anywhere else # matched first), but allow Kerberos 5 connections from anywhere else
# on the Internet. The zero mask means that no bits of the host IP # on the Internet. The zero mask means that no bits of the host IP
# address are considered so it matches any host. # address are considered so it matches any host.
# #
...@@ -527,7 +499,7 @@ local db1,db2,@demodbs all md5 ...@@ -527,7 +499,7 @@ local db1,db2,@demodbs all md5
<sect1 id="auth-methods"> <sect1 id="auth-methods">
<title>Authentication methods</title> <title>Authentication methods</title>
<para> <para>
The following describes the authentication methods in more detail. The following subsections describe the authentication methods in more detail.
</para> </para>
<sect2 id="auth-trust"> <sect2 id="auth-trust">
...@@ -538,9 +510,10 @@ local db1,db2,@demodbs all md5 ...@@ -538,9 +510,10 @@ local db1,db2,@demodbs all md5
<productname>PostgreSQL</productname> assumes that anyone who can <productname>PostgreSQL</productname> assumes that anyone who can
connect to the server is authorized to access the database with connect to the server is authorized to access the database with
whatever database user they specify (including the database superuser). whatever database user they specify (including the database superuser).
Of course, restrictions placed in the <literal>user</> column still apply. Of course, restrictions made in the <literal>database</> and
This method should only be used when there is adequate operating system-level <literal>user</> columns still apply.
protection on connections to the server. This method should only be used when there is adequate
operating-system-level protection on connections to the server.
</para> </para>
<para> <para>
...@@ -594,7 +567,13 @@ local db1,db2,@demodbs all md5 ...@@ -594,7 +567,13 @@ local db1,db2,@demodbs all md5
The password-based authentication methods are <literal>md5</>, The password-based authentication methods are <literal>md5</>,
<literal>crypt</>, and <literal>password</>. These methods operate <literal>crypt</>, and <literal>password</>. These methods operate
similarly except for the way that the password is sent across the similarly except for the way that the password is sent across the
connection. If you are at all concerned about password connection. But only <literal>md5</> supports encrypted
passwords stored in <structname>pg_shadow</structname>;
the other two require unencrypted passwords to be stored there.
</para>
<para>
If you are at all concerned about password
<quote>sniffing</> attacks then <literal>md5</> is preferred, with <quote>sniffing</> attacks then <literal>md5</> is preferred, with
<literal>crypt</> a second choice if you must support pre-7.2 <literal>crypt</> a second choice if you must support pre-7.2
clients. Plain <literal>password</> should especially be avoided for clients. Plain <literal>password</> should especially be avoided for
...@@ -606,19 +585,12 @@ local db1,db2,@demodbs all md5 ...@@ -606,19 +585,12 @@ local db1,db2,@demodbs all md5
<productname>PostgreSQL</productname> database passwords are <productname>PostgreSQL</productname> database passwords are
separate from operating system user passwords. The password for separate from operating system user passwords. The password for
each database user is stored in the <literal>pg_shadow</> system each database user is stored in the <literal>pg_shadow</> system
catalog table. Passwords can be managed with the SQL catalog table. Passwords can be managed with the SQL commands
commands <command>CREATE USER</command> and <command>ALTER <xref linkend="sql-createuser" endterm="sql-createuser-title"> and
USER</command>, e.g., <userinput>CREATE USER foo WITH PASSWORD <xref linkend="sql-alteruser" endterm="sql-alteruser-title">,
'secret';</userinput>. By default, that is, if no password has e.g., <userinput>CREATE USER foo WITH PASSWORD 'secret';</userinput>.
been set up, the stored password is null and By default, that is, if no password has been set up, the stored password
password authentication will always fail for that user. is null and password authentication will always fail for that user.
</para>
<para>
To restrict the set of users that are allowed to connect to
certain databases, list the users in the <replaceable>user</>
column of <filename>pg_hba.conf</filename>, as explained in the
previous section.
</para> </para>
</sect2> </sect2>
...@@ -634,7 +606,7 @@ local db1,db2,@demodbs all md5 ...@@ -634,7 +606,7 @@ local db1,db2,@demodbs all md5
<productname>Kerberos</productname> is an industry-standard secure <productname>Kerberos</productname> is an industry-standard secure
authentication system suitable for distributed computing over a public authentication system suitable for distributed computing over a public
network. A description of the <productname>Kerberos</productname> system network. A description of the <productname>Kerberos</productname> system
is far beyond the scope of this document; in all generality it can be is far beyond the scope of this document; in full generality it can be
quite complex (yet powerful). The <ulink quite complex (yet powerful). The <ulink
url="http://www.nrl.navy.mil/CCS/people/kenh/kerberos-faq.html">Kerberos url="http://www.nrl.navy.mil/CCS/people/kenh/kerberos-faq.html">Kerberos
<acronym>FAQ</></ulink> or <ulink url="ftp://athena-dist.mit.edu">MIT <acronym>FAQ</></ulink> or <ulink url="ftp://athena-dist.mit.edu">MIT
...@@ -680,9 +652,9 @@ local db1,db2,@demodbs all md5 ...@@ -680,9 +652,9 @@ local db1,db2,@demodbs all md5
<para> <para>
Make sure that your server key file is readable (and preferably Make sure that your server key file is readable (and preferably
only readable) by the <productname>PostgreSQL</productname> server only readable) by the <productname>PostgreSQL</productname> server
account. (See also <xref linkend="postgres-user">). The location account. (See also <xref linkend="postgres-user">.) The location
of the key file is specified by the <xref of the key file is specified by the <xref
linkend="guc-krb-server-keyfile"> run-time configuration linkend="guc-krb-server-keyfile"> configuration
parameter. (See also <xref linkend="runtime-config">.) The default parameter. (See also <xref linkend="runtime-config">.) The default
is <filename>/etc/srvtab</> if you are using Kerberos 4 and is <filename>/etc/srvtab</> if you are using Kerberos 4 and
<filename>/usr/local/pgsql/etc/krb5.keytab</> (or whichever <filename>/usr/local/pgsql/etc/krb5.keytab</> (or whichever
...@@ -728,10 +700,10 @@ local db1,db2,@demodbs all md5 ...@@ -728,10 +700,10 @@ local db1,db2,@demodbs all md5
</indexterm> </indexterm>
<para> <para>
The ident authentication method works by inspecting the client's The ident authentication method works by obtaining the client's
operating system user name and determining the allowed database operating system user name and determining the allowed database
user names by using a map file that lists the permitted user names using a map file that lists the permitted
corresponding user name pairs. The determination of the client's corresponding pairs of names. The determination of the client's
user name is the security-critical point, and it works differently user name is the security-critical point, and it works differently
depending on the connection type. depending on the connection type.
</para> </para>
...@@ -791,14 +763,15 @@ local db1,db2,@demodbs all md5 ...@@ -791,14 +763,15 @@ local db1,db2,@demodbs all md5
<para> <para>
On systems without <symbol>SO_PEERCRED</> requests, ident On systems without <symbol>SO_PEERCRED</> requests, ident
authentication is only available for TCP/IP connections. As a authentication is only available for TCP/IP connections. As a
work around, it is possible to specify the <systemitem work-around, it is possible to specify the <systemitem
class="systemname">localhost</> address <systemitem class="systemname">localhost</> address <systemitem
class="systemname">127.0.0.1</> and make connections to this class="systemname">127.0.0.1</> and make connections to this
address. address. This method is trustworthy to the extent that you trust
the local ident server.
</para> </para>
</sect3> </sect3>
<sect3> <sect3 id="auth-ident-maps">
<title>Ident Maps</title> <title>Ident Maps</title>
<para> <para>
...@@ -815,21 +788,26 @@ local db1,db2,@demodbs all md5 ...@@ -815,21 +788,26 @@ local db1,db2,@demodbs all md5
</para> </para>
<para> <para>
Ident maps Ident maps other than <literal>sameuser</literal> are defined in the
other than <literal>sameuser</literal> are defined in the file ident map file, which by default is named
<filename>pg_ident.conf</filename><indexterm><primary>pg_ident.conf</primary></indexterm> <filename>pg_ident.conf</><indexterm><primary>pg_ident.conf</primary></indexterm>
in the data directory, which contains lines of the general form: and is stored in the
cluster's data directory. (It is possible to place the map file
elsewhere, however; see the <xref linkend="guc-ident-file">
configuration parameter.)
The ident map file contains lines of the general form:
<synopsis> <synopsis>
<replaceable>map-name</> <replaceable>ident-username</> <replaceable>database-username</> <replaceable>map-name</> <replaceable>ident-username</> <replaceable>database-username</>
</synopsis> </synopsis>
Comments and whitespace are handled in the usual way. The Comments and whitespace are handled in the same way as in
<filename>pg_hba.conf</>. The
<replaceable>map-name</> is an arbitrary name that will be used to <replaceable>map-name</> is an arbitrary name that will be used to
refer to this mapping in <filename>pg_hba.conf</filename>. The other refer to this mapping in <filename>pg_hba.conf</filename>. The other
two fields specify which operating system user is allowed to connect two fields specify which operating system user is allowed to connect
as which database user. The same <replaceable>map-name</> can be as which database user. The same <replaceable>map-name</> can be
used repeatedly to specify more user-mappings within a single map. used repeatedly to specify more user-mappings within a single map.
There is no restriction regarding how many database users a given There is no restriction regarding how many database users a given
operating system user may correspond to and vice versa. operating system user may correspond to, nor vice versa.
</para> </para>
<para> <para>
...@@ -875,7 +853,7 @@ omicron bryanh guest1 ...@@ -875,7 +853,7 @@ omicron bryanh guest1
</sect2> </sect2>
<sect2 id="auth-pam"> <sect2 id="auth-pam">
<title>PAM Authentication</title> <title>PAM authentication</title>
<indexterm zone="auth-pam"> <indexterm zone="auth-pam">
<primary>PAM</primary> <primary>PAM</primary>
...@@ -886,9 +864,9 @@ omicron bryanh guest1 ...@@ -886,9 +864,9 @@ omicron bryanh guest1
<literal>password</literal> except that it uses PAM (Pluggable <literal>password</literal> except that it uses PAM (Pluggable
Authentication Modules) as the authentication mechanism. The Authentication Modules) as the authentication mechanism. The
default PAM service name is <literal>postgresql</literal>. You can default PAM service name is <literal>postgresql</literal>. You can
optionally supply you own service name after the <literal>pam</> optionally supply your own service name after the <literal>pam</>
key word in the file <filename>pg_hba.conf</filename>. For more information about PAM, please read key word in the file <filename>pg_hba.conf</filename>.
the <ulink For more information about PAM, please read the <ulink
url="http://www.kernel.org/pub/linux/libs/pam/"><productname>Linux-PAM</> url="http://www.kernel.org/pub/linux/libs/pam/"><productname>Linux-PAM</>
Page</ulink> and the <ulink Page</ulink> and the <ulink
url="http://www.sun.com/software/solaris/pam/"><systemitem url="http://www.sun.com/software/solaris/pam/"><systemitem
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.22 2004/12/26 23:06:56 tgl Exp $
--> -->
<chapter id="install-win32"> <chapter id="install-win32">
...@@ -11,9 +11,9 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo ...@@ -11,9 +11,9 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo
</indexterm> </indexterm>
<para> <para>
Although <productname>PostgreSQL</productname> is written for Although a complete <productname>PostgreSQL</productname> installation
Unix-like operating systems and can be built using for <productname>Windows</> can only be built using
<productname>MinGW</productname> and <productname>MinGW</productname> or
<productname>Cygwin</productname>, the C client library <productname>Cygwin</productname>, the C client library
(<application>libpq</application>) and the interactive terminal (<application>libpq</application>) and the interactive terminal
(<application>psql</application>) can be compiled using other Windows (<application>psql</application>) can be compiled using other Windows
...@@ -25,10 +25,9 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo ...@@ -25,10 +25,9 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo
<tip> <tip>
<para> <para>
If you are using a Windows NT-based operating system or newer you can Using <productname>MinGW</productname> or
build and use all of <productname>PostgreSQL</productname> <quote>the <productname>Cygwin</productname> is preferred. If using one of
Unix way</quote> if you install the <productname>MinGW</productname> those tool sets, see <xref linkend="installation">.
toolkit first. In that case see <xref linkend="installation">.
</para> </para>
</tip> </tip>
...@@ -110,7 +109,7 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo ...@@ -110,7 +109,7 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo
on this machine, you will have to add the on this machine, you will have to add the
<filename>src\include</filename> and <filename>src\include</filename> and
<filename>src\interfaces\libpq</filename> subdirectories of the source <filename>src\interfaces\libpq</filename> subdirectories of the source
tree to the include path in your compilers settings. tree to the include path in your compiler's settings.
</para> </para>
<para> <para>
...@@ -123,10 +122,10 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo ...@@ -123,10 +122,10 @@ $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.21 2004/12/24 19:20:18 mo
<application>psql</application> is compiled as a <quote>console <application>psql</application> is compiled as a <quote>console
application</>. As the Windows console windows use a different application</>. As the Windows console windows use a different
encoding than the rest of the system, you must take special care encoding than the rest of the system, you must take special care
when using 8-bit characters at the <application>psql</application> when using 8-bit characters within <application>psql</application>.
prompt. When <application>psql</application> detects a problematic If <application>psql</application> detects a problematic
console code page, it will warn you at startup. To change the console code page, it will warn you at startup. To change the
console code page, two things are neccessary: console code page, two things are necessary:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.220 2004/12/24 19:20:18 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.221 2004/12/26 23:06:56 tgl Exp $ -->
<chapter id="installation"> <chapter id="installation">
<title><![%standalone-include[<productname>PostgreSQL</>]]> <title><![%standalone-include[<productname>PostgreSQL</>]]>
...@@ -109,7 +109,10 @@ su - postgres ...@@ -109,7 +109,10 @@ su - postgres
<filename>configure</>. (On <productname>NetBSD</productname>, <filename>configure</>. (On <productname>NetBSD</productname>,
the <filename>libedit</filename> library is the <filename>libedit</filename> library is
<productname>Readline</productname>-compatible and is used if <productname>Readline</productname>-compatible and is used if
<filename>libreadline</filename> is not found.) <filename>libreadline</filename> is not found.) If you are using
a package-based Linux distribution, be aware that you need both
the <literal>readline</> and <literal>readline-devel</> packages,
if those are separate in your distribution.
</para> </para>
</listitem> </listitem>
...@@ -120,14 +123,22 @@ su - postgres ...@@ -120,14 +123,22 @@ su - postgres
<secondary>on Windows</secondary> <secondary>on Windows</secondary>
</indexterm> </indexterm>
To build on <productname>NT</>-based versions of Additional software is needed to build
<productname>Windows</> like Windows XP and 2003 see <productname>PostgreSQL</productname> on <productname>Windows</>.
<filename>doc/FAQ_MINGW</>. For earlier <productname>Windows</> You can build <productname>PostgreSQL</productname> for
releases see <filename>doc/FAQ_CYGWIN</>. <productname>NT</>-based versions of <productname>Windows</>
(like Windows XP and 2003) using <productname>MinGW</productname>;
To build <productname>Windows</> client-only interfaces using see <filename>doc/FAQ_MINGW</> for details. You can also build
tools like <productname>Visual C++</> and <productname>Borland <productname>PostgreSQL</productname> using
C++</> see <productname>Cygwin</productname>; see <filename>doc/FAQ_CYGWIN</>.
A <productname>Cygwin</productname>-based build will work on older
versions of <productname>Windows</>, but if you have a choice,
we recommend the <productname>MinGW</productname> approach.
While these are the only tool sets recommended for a complete build,
it is possible to build just the C client library
(<application>libpq</application>) and the interactive terminal
(<application>psql</application>) using other <productname>Windows</>
tool sets. For details of that see
<![%standalone-include[the documentation chapter "Client-Only <![%standalone-include[the documentation chapter "Client-Only
Installation on Windows"]]> <![%standalone-ignore[<xref Installation on Windows"]]> <![%standalone-ignore[<xref
linkend="install-win32">]]>. linkend="install-win32">]]>.
...@@ -245,7 +256,7 @@ su - postgres ...@@ -245,7 +256,7 @@ su - postgres
<listitem> <listitem>
<para> <para>
<application>Kerberos</>, <productname>OpenSSL</>, or <application>Kerberos</>, <productname>OpenSSL</>, and/or
<application>PAM</>, if you want to support authentication or <application>PAM</>, if you want to support authentication or
encryption using these services. encryption using these services.
</para> </para>
...@@ -271,7 +282,7 @@ su - postgres ...@@ -271,7 +282,7 @@ su - postgres
<primary>yacc</primary> <primary>yacc</primary>
</indexterm> </indexterm>
<application>Flex</> and <application>Bison</> GNU <application>Flex</> and <application>Bison</>
are needed to build a CVS checkout or if you changed the actual are needed to build a CVS checkout or if you changed the actual
scanner and parser definition files. If you need them, be sure scanner and parser definition files. If you need them, be sure
to get <application>Flex</> 2.5.4 or later and to get <application>Flex</> 2.5.4 or later and
...@@ -299,7 +310,7 @@ su - postgres ...@@ -299,7 +310,7 @@ su - postgres
25 MB, databases take about five times the amount of space that a 25 MB, databases take about five times the amount of space that a
flat text file with the same data would take. If you are going to flat text file with the same data would take. If you are going to
run the regression tests you will temporarily need up to an extra run the regression tests you will temporarily need up to an extra
90 MB. Use the <command>df</command> command to check for disk 90 MB. Use the <command>df</command> command to check free disk
space. space.
</para> </para>
</sect1> </sect1>
...@@ -416,9 +427,11 @@ su - postgres ...@@ -416,9 +427,11 @@ su - postgres
<para> <para>
Very old versions might not have <application>pg_ctl</>. If you Very old versions might not have <application>pg_ctl</>. If you
can't find it or it doesn't work, find out the process ID of the can't find it or it doesn't work, find out the process ID of the
old server, for old server, for example by typing
example by typing <userinput>ps ax | grep postmaster</>, and <screen>
signal it to stop this way: <userinput>ps ax | grep postmaster</userinput>
</screen>
and signal it to stop this way:
<screen> <screen>
<userinput>kill -INT <replaceable>processID</></userinput> <userinput>kill -INT <replaceable>processID</></userinput>
</screen> </screen>
...@@ -1108,8 +1121,10 @@ All of PostgreSQL is successfully made. Ready to install. ...@@ -1108,8 +1121,10 @@ All of PostgreSQL is successfully made. Ready to install.
program, so that you can rebuild everything with <command>gmake</> program, so that you can rebuild everything with <command>gmake</>
later on. To reset the source tree to the state in which it was later on. To reset the source tree to the state in which it was
distributed, use <command>gmake distclean</>. If you are going to distributed, use <command>gmake distclean</>. If you are going to
build for several platforms from the same source tree you must do build for several platforms within the same source tree you must do
this and re-configure for each build. this and re-configure for each build. (Alternatively, use
a separate build tree for each platform, so that the source tree
remains unmodified.)
</para> </para>
</formalpara> </formalpara>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.299 2004/12/26 23:06:56 tgl Exp $
--> -->
<Chapter Id="runtime"> <Chapter Id="runtime">
...@@ -7,7 +7,7 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp ...@@ -7,7 +7,7 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp
<Para> <Para>
This chapter discusses how to set up and run the database server This chapter discusses how to set up and run the database server
and the interactions with the operating system. and its interactions with the operating system.
</para> </para>
<sect1 id="postgres-user"> <sect1 id="postgres-user">
...@@ -18,7 +18,7 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp ...@@ -18,7 +18,7 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp
</indexterm> </indexterm>
<para> <para>
As with any other server daemon that is connected to outside world, As with any other server daemon that is accessible to the outside world,
it is advisable to run <productname>PostgreSQL</productname> under a it is advisable to run <productname>PostgreSQL</productname> under a
separate user account. This user account should only own the data separate user account. This user account should only own the data
that is managed by the server, and should not be shared with other that is managed by the server, and should not be shared with other
...@@ -31,8 +31,8 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp ...@@ -31,8 +31,8 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp
<para> <para>
To add a Unix user account to your system, look for a command To add a Unix user account to your system, look for a command
<command>useradd</command> or <command>adduser</command>. The user <command>useradd</command> or <command>adduser</command>. The user
name <systemitem>postgres</systemitem> is often used but is by no name <systemitem>postgres</systemitem> is often used, and is assumed
means required. throughout this book, but you can use another name if you like.
</para> </para>
</sect1> </sect1>
...@@ -51,14 +51,14 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp ...@@ -51,14 +51,14 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp
<para> <para>
Before you can do anything, you must initialize a database storage Before you can do anything, you must initialize a database storage
area on disk. We call this a <firstterm>database cluster</firstterm>. area on disk. We call this a <firstterm>database cluster</firstterm>.
(<acronym>SQL</acronym> uses the term catalog cluster instead.) A (<acronym>SQL</acronym> uses the term catalog cluster.) A
database cluster is a collection of databases is accessible by a database cluster is a collection of databases that is managed by a
single instance of a running database server. After initialization, a single instance of a running database server. After initialization, a
database cluster will contain a database named database cluster will contain a database named
<literal>template1</literal>. As the name suggests, this will be used <literal>template1</literal>. As the name suggests, this will be used
as a template for subsequently created databases; it should not be as a template for subsequently created databases; it should not be
used for actual work. (See <xref linkend="managing-databases"> for information used for actual work. (See <xref linkend="managing-databases"> for
about creating databases.) information about creating new databases within a cluster.)
</para> </para>
<para> <para>
...@@ -71,7 +71,7 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp ...@@ -71,7 +71,7 @@ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.298 2004/12/18 18:36:33 tgl Exp
<filename>/var/lib/pgsql/data</filename> are popular. To initialize a <filename>/var/lib/pgsql/data</filename> are popular. To initialize a
database cluster, use the command <command>initdb</command>,<indexterm><primary>initdb</></> which is database cluster, use the command <command>initdb</command>,<indexterm><primary>initdb</></> which is
installed with <productname>PostgreSQL</productname>. The desired installed with <productname>PostgreSQL</productname>. The desired
file system location of your database system is indicated by the file system location of your database cluster is indicated by the
<option>-D</option> option, for example <option>-D</option> option, for example
<screen> <screen>
<prompt>$</> <userinput>initdb -D /usr/local/pgsql/data</userinput> <prompt>$</> <userinput>initdb -D /usr/local/pgsql/data</userinput>
...@@ -107,7 +107,7 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput> ...@@ -107,7 +107,7 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput>
<para> <para>
<command>initdb</command> will refuse to run if the data directory <command>initdb</command> will refuse to run if the data directory
looks like it it has already been initialized.</para> looks like it has already been initialized.</para>
<para> <para>
Because the data directory contains all the data stored in the Because the data directory contains all the data stored in the
...@@ -123,14 +123,15 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput> ...@@ -123,14 +123,15 @@ postgres$ <userinput>initdb -D /usr/local/pgsql/data</userinput>
database and even become the database superuser. If you do not database and even become the database superuser. If you do not
trust other local users, we recommend you use one of trust other local users, we recommend you use one of
<command>initdb</command>'s <option>-W</option>, <option>--pwprompt</option> <command>initdb</command>'s <option>-W</option>, <option>--pwprompt</option>
or <option>--pwfile</option> option to assign a password to the or <option>--pwfile</option> options to assign a password to the
database superuser.<indexterm><primary>password</><secondary>of the database superuser.<indexterm><primary>password</><secondary>of the
superuser</></indexterm> After <command>initdb</command>, modify superuser</></indexterm> Also, specify <option>-A md5</> or
the <filename>pg_hba.conf</filename> file to use <literal>md5</> or <option>-A password</> so that the default <literal>trust</> authentication
<literal>password</> instead of <literal>trust</> authentication mode is not used; or modify the generated <filename>pg_hba.conf</filename>
file after running <command>initdb</command>,
<emphasis>before</> you start the server for the first time. (Other <emphasis>before</> you start the server for the first time. (Other
approaches include using <literal>ident</literal> authentication or reasonable approaches include using <literal>ident</literal> authentication
file system permissions to restrict connections. See <xref or file system permissions to restrict connections. See <xref
linkend="client-authentication"> for more information.) linkend="client-authentication"> for more information.)
</para> </para>
...@@ -185,22 +186,23 @@ $ <userinput>postmaster -D /usr/local/pgsql/data &gt;logfile 2&gt;&amp;1 &amp;</ ...@@ -185,22 +186,23 @@ $ <userinput>postmaster -D /usr/local/pgsql/data &gt;logfile 2&gt;&amp;1 &amp;</
<para> <para>
The <command>postmaster</command> also takes a number of other The <command>postmaster</command> also takes a number of other
command line options. For more information, see the reference page command line options. For more information, see the
<xref linkend="app-postmaster"> reference page
and <xref linkend="runtime-config"> below. and <xref linkend="runtime-config"> below.
</para> </para>
<para> <para>
This shell syntax can get tedious quickly. Therefore the shell This shell syntax can get tedious quickly. Therefore the wrapper
script wrapper program
<command>pg_ctl</command><indexterm><primary>pg_ctl</primary></indexterm> <xref linkend="app-pg-ctl"><indexterm><primary>pg_ctl</primary></indexterm>
is provided to simplify some tasks. For example: is provided to simplify some tasks. For example:
<programlisting> <programlisting>
pg_ctl start -l logfile pg_ctl start -l logfile
</programlisting> </programlisting>
will start the server in the background and put the output into the will start the server in the background and put the output into the
named log file. The <option>-D</option> option has the same meaning named log file. The <option>-D</option> option has the same meaning
here as in the <command>postmaster</command>. <command>pg_ctl</command> is also here as in the <command>postmaster</command>. <command>pg_ctl</command>
capable of stopping the server. is also capable of stopping the server.
</para> </para>
<para> <para>
...@@ -453,19 +455,20 @@ psql: could not connect to server: No such file or directory ...@@ -453,19 +455,20 @@ psql: could not connect to server: No such file or directory
<para> <para>
All parameter names are case-insensitive. Every parameter takes a All parameter names are case-insensitive. Every parameter takes a
value of one of the four types: boolean, integer, floating point, value of one of four types: boolean, integer, floating point,
and string. Boolean values are <literal>ON</literal>, or string. Boolean values may be written as <literal>ON</literal>,
<literal>OFF</literal>, <literal>TRUE</literal>, <literal>OFF</literal>, <literal>TRUE</literal>,
<literal>FALSE</literal>, <literal>YES</literal>, <literal>FALSE</literal>, <literal>YES</literal>,
<literal>NO</literal>, <literal>1</literal>, <literal>0</literal> <literal>NO</literal>, <literal>1</literal>, <literal>0</literal>
(case-insensitive) or any non-ambiguous prefix of these. (all case-insensitive) or any unambiguous prefix of these.
</para> </para>
<para> <para>
One way to set these parameters is to edit the file One way to set these parameters is to edit the file
<filename>postgresql.conf</filename><indexterm><primary>postgresql.conf</></> <filename>postgresql.conf</><indexterm><primary>postgresql.conf</></>,
in the data directory. (A default file is installed there.) An which is normally kept in the data directory. (<command>initdb</>
example of what this file might look like is: installs a default copy there.) An example of what this file might look
like is:
<programlisting> <programlisting>
# This is a comment # This is a comment
log_connections = yes log_connections = yes
...@@ -476,7 +479,7 @@ search_path = '$user, public' ...@@ -476,7 +479,7 @@ search_path = '$user, public'
value is optional. Whitespace is insignificant and blank lines are value is optional. Whitespace is insignificant and blank lines are
ignored. Hash marks (<literal>#</literal>) introduce comments ignored. Hash marks (<literal>#</literal>) introduce comments
anywhere. Parameter values that are not simple identifiers or anywhere. Parameter values that are not simple identifiers or
numbers should be single-quoted. numbers must be single-quoted.
</para> </para>
<para> <para>
...@@ -502,11 +505,14 @@ search_path = '$user, public' ...@@ -502,11 +505,14 @@ search_path = '$user, public'
postmaster -c log_connections=yes -c log_destination='syslog' postmaster -c log_connections=yes -c log_destination='syslog'
</programlisting> </programlisting>
Command-line options override any conflicting settings in Command-line options override any conflicting settings in
<filename>postgresql.conf</filename>. <filename>postgresql.conf</filename>. Note that this means you won't
be able to change the value on-the-fly by editing
<filename>postgresql.conf</filename>, so while the command-line
method may be convenient, it can cost you flexibility later.
</para> </para>
<para> <para>
Occasionally it is also useful to give a command line option to Occasionally it is useful to give a command line option to
one particular session only. The environment variable one particular session only. The environment variable
<envar>PGOPTIONS</envar> can be used for this purpose on the <envar>PGOPTIONS</envar> can be used for this purpose on the
client side: client side:
...@@ -515,18 +521,16 @@ env PGOPTIONS='-c geqo=off' psql ...@@ -515,18 +521,16 @@ env PGOPTIONS='-c geqo=off' psql
</programlisting> </programlisting>
(This works for any <application>libpq</>-based client application, not (This works for any <application>libpq</>-based client application, not
just <application>psql</application>.) Note that this won't work for just <application>psql</application>.) Note that this won't work for
parameters that are fixed when the server is started, nor for parameters that are fixed when the server is started or that must be
parameters that require superuser permissions to change (not even specified in <filename>postgresql.conf</filename>.
if you are logging in as superuser).
</para> </para>
<para> <para>
Furthermore, it is possible to assign a set of option settings to Furthermore, it is possible to assign a set of option settings to
a user or a database. Whenever a session is started, the default a user or a database. Whenever a session is started, the default
settings for the user and database involved are loaded. The settings for the user and database involved are loaded. The
commands <xref linkend="sql-alterdatabase" commands <xref linkend="sql-alteruser" endterm="sql-alteruser-title">
endterm="sql-alterdatabase-title"> and <xref and <xref linkend="sql-alterdatabase" endterm="sql-alterdatabase-title">,
linkend="sql-alteruser" endterm="sql-alteruser-title">,
respectively, are used to configure these settings. Per-database respectively, are used to configure these settings. Per-database
settings override anything received from the settings override anything received from the
<command>postmaster</command> command-line or the configuration <command>postmaster</command> command-line or the configuration
...@@ -546,8 +550,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -546,8 +550,8 @@ SET ENABLE_SEQSCAN TO OFF;
<command>SET</command>: for example, if they control behavior that <command>SET</command>: for example, if they control behavior that
cannot reasonably be changed without restarting cannot reasonably be changed without restarting
<productname>PostgreSQL</productname>. Also, some parameters can <productname>PostgreSQL</productname>. Also, some parameters can
be modified via <command>SET</command> by superusers, but not by be modified via <command>SET</command> or <command>ALTER</> by superusers,
ordinary users. but not by ordinary users.
</para> </para>
<para> <para>
...@@ -567,6 +571,20 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -567,6 +571,20 @@ SET ENABLE_SEQSCAN TO OFF;
<sect2 id="runtime-config-file-locations"> <sect2 id="runtime-config-file-locations">
<title>File Locations</title> <title>File Locations</title>
<para>
In addition to the <filename>postgresql.conf</filename> file
already mentioned, <productname>PostgreSQL</productname> uses
two other manually-edited configuration files, which control
client authentication (their use is discussed in <xref
linkend="client-authentication">).
By default, all three configuration files are stored
in the database cluster's data directory. The options described
in this subsection allow the configuration files to be placed elsewhere.
(Doing so can ease administration. In particular it is often
easier to ensure that the configuration files are properly backed-up
when they are kept separate.)
</para>
<variablelist> <variablelist>
<varlistentry id="guc-data-directory" xreflabel="data_directory"> <varlistentry id="guc-data-directory" xreflabel="data_directory">
<term><varname>data_directory</varname> (<type>string</type>)</term> <term><varname>data_directory</varname> (<type>string</type>)</term>
...@@ -602,7 +620,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -602,7 +620,8 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Specifies the configuration file for host-based authentication. Specifies the configuration file for host-based authentication
(customarily called <filename>pg_hba.conf</>).
This option can only be set at server start. This option can only be set at server start.
</para> </para>
</listitem> </listitem>
...@@ -616,7 +635,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -616,7 +635,8 @@ SET ENABLE_SEQSCAN TO OFF;
<listitem> <listitem>
<para> <para>
Specifies the configuration file for Specifies the configuration file for
<application>ident</> authentication. <application>ident</> authentication
(customarily called <filename>pg_ident.conf</>).
This option can only be set at server start. This option can only be set at server start.
</para> </para>
</listitem> </listitem>
...@@ -629,9 +649,9 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -629,9 +649,9 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Specifies that the <application>postmaster</> should create an Specifies the name of an additional process-id (PID) file that the
additional process-id (PID) file for use by server administration <application>postmaster</> should create for use by server
programs. administration programs.
This option can only be set at server start. This option can only be set at server start.
</para> </para>
</listitem> </listitem>
...@@ -639,24 +659,23 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -639,24 +659,23 @@ SET ENABLE_SEQSCAN TO OFF;
</variablelist> </variablelist>
<para> <para>
In a default installation, none of the above options is set explicitly In a default installation, none of the above options are set explicitly.
in the <filename>postgresql.conf</filename> file. Instead, the Instead, the
data directory is specified by the <option>-D</option> command-line data directory is specified by the <option>-D</option> command-line
option or the <envar>PGDATA</envar> environment variable, and the option or the <envar>PGDATA</envar> environment variable, and the
configuration files are all placed within the data directory. configuration files are all found within the data directory.
</para> </para>
<para> <para>
It is also possible to separate the configuration files from the data If you wish to keep the configuration files elsewhere than the
directory, which can ease administration. (In particular it is often data directory, the postmaster's <option>-D</option>
easier to ensure that the configuration files are properly backed-up
when they are kept separate.) To do this, the <option>-D</option>
command-line option or <envar>PGDATA</envar> environment variable command-line option or <envar>PGDATA</envar> environment variable
must point to the directory containing the configuration files, must point to the directory containing the configuration files,
and the <varname>data_directory</> option is set in and the <varname>data_directory</> option must be set in
<filename>postgresql.conf</filename> (or on the command line) to show <filename>postgresql.conf</filename> (or on the command line) to show
where the data directory is actually located. Notice that where the data directory is actually located. Notice that
<varname>data_directory</> overrides <option>-D</option> for the location <varname>data_directory</> overrides <option>-D</option> and
<envar>PGDATA</envar> for the location
of the data directory, but not for the location of the configuration of the data directory, but not for the location of the configuration
files. files.
</para> </para>
...@@ -756,7 +775,7 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -756,7 +775,7 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Determines the number of <quote>connection slots</quote> that Determines the number of connection <quote>slots</quote> that
are reserved for connections by <productname>PostgreSQL</> are reserved for connections by <productname>PostgreSQL</>
superusers. At most <xref linkend="guc-max-connections"> superusers. At most <xref linkend="guc-max-connections">
connections can ever be active simultaneously. Whenever the connections can ever be active simultaneously. Whenever the
...@@ -816,8 +835,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -816,8 +835,8 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Sets the access permissions of the Unix-domain socket. Unix Sets the access permissions of the Unix-domain socket. Unix-domain
domain sockets use the usual Unix file system permission set. sockets use the usual Unix file system permission set.
The option value is expected to be a numeric mode The option value is expected to be a numeric mode
specification in the form accepted by the specification in the form accepted by the
<function>chmod</function> and <function>umask</function> <function>chmod</function> and <function>umask</function>
...@@ -830,8 +849,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -830,8 +849,8 @@ SET ENABLE_SEQSCAN TO OFF;
anyone can connect. Reasonable alternatives are anyone can connect. Reasonable alternatives are
<literal>0770</literal> (only user and group, see also <literal>0770</literal> (only user and group, see also
<varname>unix_socket_group</varname>) and <literal>0700</literal> <varname>unix_socket_group</varname>) and <literal>0700</literal>
(only user). (Note that actually for a Unix domain socket, only write (only user). (Note that for a Unix-domain socket, only write
permission matters and there is no point in setting or revoking permission matters and so there is no point in setting or revoking
read or execute permissions.) read or execute permissions.)
</para> </para>
...@@ -855,8 +874,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -855,8 +874,8 @@ SET ENABLE_SEQSCAN TO OFF;
<para> <para>
Specifies the <productname>Rendezvous</productname> broadcast Specifies the <productname>Rendezvous</productname> broadcast
name. By default, the computer name is used, specified as an name. By default, the computer name is used, specified as an
empty string ''. This option is only meaningful on platforms empty string ''. This option is ignored if the server was not
that support <productname>Rendezvous</productname>. This compiled with <productname>Rendezvous</productname> support. This
option can only be set at server start. option can only be set at server start.
</para> </para>
</listitem> </listitem>
...@@ -1163,8 +1182,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -1163,8 +1182,8 @@ SET ENABLE_SEQSCAN TO OFF;
</para> </para>
<para> <para>
If <literal>mylib</> or <literal>mylib_init</> are not found, the If a specified library or initialization function is not found,
server will fail to start. the server will fail to start.
</para> </para>
<para> <para>
...@@ -1179,8 +1198,9 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -1179,8 +1198,9 @@ SET ENABLE_SEQSCAN TO OFF;
By preloading a shared library (and initializing it if By preloading a shared library (and initializing it if
applicable), the library startup time is avoided when the applicable), the library startup time is avoided when the
library is first used. However, the time to start each new library is first used. However, the time to start each new
server process may increase, even if that process never server process may increase slightly, even if that process never
uses the library. uses the library. So this option is recommended only for
libraries that will be used in most sessions.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1589,7 +1609,7 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -1589,7 +1609,7 @@ SET ENABLE_SEQSCAN TO OFF;
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Write a message to the server logs if checkpoints caused by Write a message to the server log if checkpoints caused by
the filling of checkpoint segment files happen closer together the filling of checkpoint segment files happen closer together
than this many seconds. The default is 30 seconds. than this many seconds. The default is 30 seconds.
Zero turns off the warning. Zero turns off the warning.
...@@ -1622,8 +1642,8 @@ SET ENABLE_SEQSCAN TO OFF; ...@@ -1622,8 +1642,8 @@ SET ENABLE_SEQSCAN TO OFF;
file. file.
</para> </para>
<para> <para>
It is important for the command to return a zero exit status only if It is important for the command to return a zero exit status if
it succeeds. Examples: and only if it succeeds. Examples:
<programlisting> <programlisting>
archive_command = 'cp "%p" /mnt/server/archivedir/"%f"' archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
...@@ -1643,20 +1663,22 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1643,20 +1663,22 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<title>Planner Method Configuration</title> <title>Planner Method Configuration</title>
<para> <para>
These configuration parameters provide a crude method for These configuration parameters provide a crude method of
influencing the query plans chosen by the query optimizer. If influencing the query plans chosen by the query optimizer. If
the default plan chosen by the optimizer for a particular query the default plan chosen by the optimizer for a particular query
is not optimal, a temporary solution may be found by using one is not optimal, a temporary solution may be found by using one
of these configuration parameters to force the optimizer to of these configuration parameters to force the optimizer to
choose a better plan. Other ways to improve the quality of the choose a different plan. Turning one of these settings off
plans chosen by the optimizer include configuring the <xref permanently is seldom a good idea, however.
Better ways to improve the quality of the
plans chosen by the optimizer include adjusting the <xref
linkend="runtime-config-query-constants" linkend="runtime-config-query-constants"
endterm="runtime-config-query-constants-title">, running <xref endterm="runtime-config-query-constants-title">, running <xref
linkend="sql-analyze" endterm="sql-analyze-title"> more linkend="sql-analyze" endterm="sql-analyze-title"> more
frequently, increasing the value of the <xref frequently, increasing the value of the <xref
linkend="guc-default-statistics-target"> configuration parameter, linkend="guc-default-statistics-target"> configuration parameter,
and increasing the amount of statistics collected for a and increasing the amount of statistics collected for
particular column using <command>ALTER TABLE SET specific columns using <command>ALTER TABLE SET
STATISTICS</command>. STATISTICS</command>.
</para> </para>
...@@ -1669,8 +1691,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1669,8 +1691,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<listitem> <listitem>
<para> <para>
Enables or disables the query planner's use of hashed Enables or disables the query planner's use of hashed
aggregation plan types. The default is on. This is used for aggregation plan types. The default is on.
debugging the query planner.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1683,8 +1704,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1683,8 +1704,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<listitem> <listitem>
<para> <para>
Enables or disables the query planner's use of hash-join plan Enables or disables the query planner's use of hash-join plan
types. The default is on. This is used for debugging the query types. The default is on.
planner.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1700,8 +1720,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1700,8 +1720,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<listitem> <listitem>
<para> <para>
Enables or disables the query planner's use of index-scan plan Enables or disables the query planner's use of index-scan plan
types. The default is on. This is used for debugging the query types. The default is on.
planner.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1714,8 +1733,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1714,8 +1733,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<listitem> <listitem>
<para> <para>
Enables or disables the query planner's use of merge-join plan Enables or disables the query planner's use of merge-join plan
types. The default is on. This is used for debugging the query types. The default is on.
planner.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1731,7 +1749,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1731,7 +1749,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
plans. It's not possible to suppress nested-loop joins entirely, plans. It's not possible to suppress nested-loop joins entirely,
but turning this variable off discourages the planner from using but turning this variable off discourages the planner from using
one if there are other methods available. The default is one if there are other methods available. The default is
on. This is used for debugging the query planner. on.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1750,7 +1768,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1750,7 +1768,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
plan types. It's not possible to suppress sequential scans plan types. It's not possible to suppress sequential scans
entirely, but turning this variable off discourages the planner entirely, but turning this variable off discourages the planner
from using one if there are other methods available. The from using one if there are other methods available. The
default is on. This is used for debugging the query planner. default is on.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1766,7 +1784,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1766,7 +1784,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
steps. It's not possible to suppress explicit sorts entirely, steps. It's not possible to suppress explicit sorts entirely,
but turning this variable off discourages the planner from but turning this variable off discourages the planner from
using one if there are other methods available. The default using one if there are other methods available. The default
is on. This is used for debugging the query planner. is on.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1779,8 +1797,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -1779,8 +1797,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<listitem> <listitem>
<para> <para>
Enables or disables the query planner's use of <acronym>TID</> Enables or disables the query planner's use of <acronym>TID</>
scan plan types. The default is on. This is used for debugging scan plan types. The default is on.
the query planner.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2383,6 +2400,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -2383,6 +2400,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
message that is logged. Valid values are <literal>TERSE</>, message that is logged. Valid values are <literal>TERSE</>,
<literal>DEFAULT</>, and <literal>VERBOSE</>, each adding more <literal>DEFAULT</>, and <literal>VERBOSE</>, each adding more
fields to displayed messages. fields to displayed messages.
Only superusers can change this setting.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2505,7 +2523,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -2505,7 +2523,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<term><literal>ERROR</literal></term> <term><literal>ERROR</literal></term>
<listitem> <listitem>
<para> <para>
Reports an error that caused the current transaction to abort. Reports an error that caused the current command to abort.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2565,15 +2583,16 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -2565,15 +2583,16 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
These options enable various debugging output to be sent to These options enable various debugging output to be emitted.
the client or server log. For each executed query, they print For each executed query, they print
the resulting parse tree, the query rewriter output, or the the resulting parse tree, the query rewriter output, or the
execution plan. <varname>debug_pretty_print</varname> indents execution plan. <varname>debug_pretty_print</varname> indents
these displays to produce a more readable but much longer these displays to produce a more readable but much longer
output format. <varname>client_min_messages</varname> or output format. <varname>client_min_messages</varname> or
<varname>log_min_messages</varname> must be <varname>log_min_messages</varname> must be
<literal>DEBUG1</literal> or lower to send the output to the <literal>DEBUG1</literal> or lower to actually send this output
client or server logs. These options are off by default. to the client or the server log, respectively.
These options are off by default.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2585,7 +2604,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -2585,7 +2604,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
This outputs a line to the server logs detailing each successful This outputs a line to the server log detailing each successful
connection. This is off by default, although it is probably very connection. This is off by default, although it is probably very
useful. This option can only be set at server start or in the useful. This option can only be set at server start or in the
<filename>postgresql.conf</filename> configuration file. <filename>postgresql.conf</filename> configuration file.
...@@ -2600,7 +2619,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -2600,7 +2619,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
This outputs a line in the server logs similar to This outputs a line in the server log similar to
<varname>log_connections</varname> but at session termination, <varname>log_connections</varname> but at session termination,
and includes the duration of the session. This is off by and includes the duration of the session. This is off by
default. This option can only be set at server start or in the default. This option can only be set at server start or in the
...@@ -2781,11 +2800,12 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -2781,11 +2800,12 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
By default, connection logs only show the IP address of the By default, connection log messages only show the IP address of the
connecting host. If you want it to show the host name you can connecting host. Turning on this option causes logging of the
turn this on, but depending on your host name resolution setup host name as well. Note that depending on your host name resolution
it might impose a non-negligible performance penalty. This setup this might impose a non-negligible performance penalty. This
option can only be set at server start. option can only be set at server start or in the
<filename>postgresql.conf</filename> file.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3039,7 +3059,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -3039,7 +3059,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
<listitem> <listitem>
<para> <para>
This parameter is normally true. When set to false, it disables This parameter is normally true. When set to false, it disables
validation of the function body string in <xref validation of the function body string during <xref
linkend="sql-createfunction" linkend="sql-createfunction"
endterm="sql-createfunction-title">. Disabling validation is endterm="sql-createfunction-title">. Disabling validation is
occasionally useful to avoid problems such as forward occasionally useful to avoid problems such as forward
...@@ -3102,7 +3122,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows ...@@ -3102,7 +3122,7 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
</indexterm> </indexterm>
<listitem> <listitem>
<para> <para>
Aborts any statement that takes over the specified number of Abort any statement that takes over the specified number of
milliseconds. A value of zero (the default) turns off the limitation. milliseconds. A value of zero (the default) turns off the limitation.
</para> </para>
</listitem> </listitem>
...@@ -3419,7 +3439,10 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' ...@@ -3419,7 +3439,10 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
The shared lock table is sized on the assumption that at most The shared lock table is sized on the assumption that at most
<varname>max_locks_per_transaction</varname> * <varname>max_locks_per_transaction</varname> *
<varname>max_connections</varname> distinct objects will need to <varname>max_connections</varname> distinct objects will need to
be locked at any one time. The default, 64, has historically be locked at any one time. (Thus, this parameter's name may be
confusing: it is not a hard limit on the number of locks taken
by any one transaction, but rather a maximum average value.)
The default, 64, has historically
proven sufficient, but you might need to raise this value if you proven sufficient, but you might need to raise this value if you
have clients that touch many different tables in a single have clients that touch many different tables in a single
transaction. This option can only be set at server start. transaction. This option can only be set at server start.
...@@ -3469,7 +3492,8 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' ...@@ -3469,7 +3492,8 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
<literal>advanced</>, <literal>extended</>, or <literal>basic</>. <literal>advanced</>, <literal>extended</>, or <literal>basic</>.
The default is <literal>advanced</>. The <literal>extended</> The default is <literal>advanced</>. The <literal>extended</>
setting may be useful for exact backwards compatibility with setting may be useful for exact backwards compatibility with
pre-7.4 releases of <productname>PostgreSQL</>. pre-7.4 releases of <productname>PostgreSQL</>. See
<xref linkend="posix-syntax-details"> for details.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3501,7 +3525,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' ...@@ -3501,7 +3525,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
<listitem> <listitem>
<para> <para>
This controls whether <command>CREATE TABLE</command> and This controls whether <command>CREATE TABLE</command> and
<command>CREATE TABLE AS</command> will include OIDs in <command>CREATE TABLE AS</command> include an OID column in
newly-created tables, if neither <literal>WITH OIDS</literal> newly-created tables, if neither <literal>WITH OIDS</literal>
nor <literal>WITHOUT OIDS</literal> is specified. It also nor <literal>WITHOUT OIDS</literal> is specified. It also
determines whether OIDs will be included in tables created by determines whether OIDs will be included in tables created by
...@@ -3589,7 +3613,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' ...@@ -3589,7 +3613,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
The following <quote>parameters</> are read-only, and are determined The following <quote>parameters</> are read-only, and are determined
when <productname>PostgreSQL</productname> is compiled or when it is when <productname>PostgreSQL</productname> is compiled or when it is
installed. As such, they have been excluded from the sample installed. As such, they have been excluded from the sample
<filename>postgresql.conf</> file. These options determine <filename>postgresql.conf</> file. These options report
various aspects of <productname>PostgreSQL</productname> behavior various aspects of <productname>PostgreSQL</productname> behavior
that may be of interest to certain applications, particularly that may be of interest to certain applications, particularly
administrative front-ends. administrative front-ends.
...@@ -3919,7 +3943,7 @@ plruby.bar = true # generates error, unknown class name ...@@ -3919,7 +3943,7 @@ plruby.bar = true # generates error, unknown class name
<para> <para>
Detection of a damaged page header normally causes Detection of a damaged page header normally causes
<productname>PostgreSQL</> to report an error, aborting the current <productname>PostgreSQL</> to report an error, aborting the current
transaction. Setting <varname>zero_damaged_pages</> to true causes command. Setting <varname>zero_damaged_pages</> to true causes
the system to instead report a warning, zero out the damaged page, the system to instead report a warning, zero out the damaged page,
and continue processing. This behavior <emphasis>will destroy data</>, and continue processing. This behavior <emphasis>will destroy data</>,
namely all the rows on the damaged page. But it allows you to get namely all the rows on the damaged page. But it allows you to get
...@@ -4170,7 +4194,7 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput> ...@@ -4170,7 +4194,7 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
<row> <row>
<entry><varname>SEMVMX</></> <entry><varname>SEMVMX</></>
<entry>Maximum value of semaphore</> <entry>Maximum value of semaphore</>
<entry>at least 1000 (The default is often 32767, don't change unless asked to.)</> <entry>at least 1000 (The default is often 32767, don't change unless forced to)</>
</row> </row>
</tbody> </tbody>
...@@ -4183,16 +4207,23 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput> ...@@ -4183,16 +4207,23 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
shared memory parameter is <varname>SHMMAX</>, the maximum size, in shared memory parameter is <varname>SHMMAX</>, the maximum size, in
bytes, of a shared memory segment. If you get an error message from bytes, of a shared memory segment. If you get an error message from
<function>shmget</> like <errorname>Invalid argument</>, it is <function>shmget</> like <errorname>Invalid argument</>, it is
possible that this limit has been exceeded. The size of the required likely that this limit has been exceeded. The size of the required
shared memory segment varies both with the number of requested shared memory segment varies both with the number of requested
buffers (<option>-B</> option) and the number of allowed connections buffers (<option>-B</> option) and the number of allowed connections
(<option>-N</> option), although the former is the most significant. (<option>-N</> option), although the former is the most significant.
(You can, as a temporary solution, lower these settings to eliminate (You can, as a temporary solution, lower these settings to eliminate
the failure.) As a rough approximation, you can estimate the the failure.) As a rough approximation, you can estimate the
required segment size by multiplying the number of buffers and the required segment size as suggested in <xref
block size (8 kB by default) plus ample overhead (at least half a linkend="sysvipc-parameters">. Any error message you might get will
megabyte). Any error message you might get will contain the size of contain the size of the failed allocation request.
the failed allocation request. </para>
<para>
Some systems also have a limit on the total amount of shared memory in
the system (<varname>SHMALL</>). Make sure this is large enough
for <productname>PostgreSQL</> plus any other applications that
are using shared memory segments. (Caution: <varname>SHMALL</>
is measured in pages rather than bytes on many systems.)
</para> </para>
<para> <para>
...@@ -4200,10 +4231,8 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput> ...@@ -4200,10 +4231,8 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
memory segments (<varname>SHMMIN</>), which should be at most memory segments (<varname>SHMMIN</>), which should be at most
approximately 256 kB for <productname>PostgreSQL</> (it is approximately 256 kB for <productname>PostgreSQL</> (it is
usually just 1). The maximum number of segments system-wide usually just 1). The maximum number of segments system-wide
(<varname>SHMMNI</>) or per-process (<varname>SHMSEG</>) should (<varname>SHMMNI</>) or per-process (<varname>SHMSEG</>) are unlikely
not cause a problem unless your system has them set to zero. Some to cause a problem unless your system has them set to zero.
systems also have a limit on the total amount of shared memory in
the system; see the platform-specific instructions below.
</para> </para>
<para> <para>
...@@ -4261,15 +4290,16 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput> ...@@ -4261,15 +4290,16 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
By default, only 4 MB of shared memory is supported. Keep in By default, only 4 MB of shared memory is supported. Keep in
mind that shared memory is not pageable; it is locked in RAM. mind that shared memory is not pageable; it is locked in RAM.
To increase the amount of shared memory supported by your To increase the amount of shared memory supported by your
system, add the following to your kernel configuration system, add something like the following to your kernel configuration
file. A <varname>SHMALL</> value of 1024 represents 4 MB of file:
shared memory. The following increases the maximum shared
memory area to 32 MB:
<programlisting> <programlisting>
options "SHMALL=8192" options "SHMALL=8192"
options "SHMMAX=\(SHMALL*PAGE_SIZE\)" options "SHMMAX=\(SHMALL*PAGE_SIZE\)"
</programlisting> </programlisting>
For those running 4.3 or later, you will probably need to increase <varname>SHMALL</> is measured in 4KB pages, so a value of
1024 represents 4 MB of shared memory. Therefore the above increases
the maximum shared memory area to 32 MB.
For those running 4.3 or later, you will probably also need to increase
<varname>KERNEL_VIRTUAL_MB</> above the default <literal>248</>. <varname>KERNEL_VIRTUAL_MB</> above the default <literal>248</>.
Once all changes have been made, recompile the kernel, and reboot. Once all changes have been made, recompile the kernel, and reboot.
</para> </para>
...@@ -4296,9 +4326,9 @@ options "SYSPTSIZE=16" ...@@ -4296,9 +4326,9 @@ options "SYSPTSIZE=16"
<formalpara> <formalpara>
<title>Semaphores</> <title>Semaphores</>
<para> <para>
You may need to increase the number of semaphores. By You will probably want to increase the number of semaphores
default, <productname>PostgreSQL</> allocates 34 semaphores, as well; the default system total of 60 will only allow about
which is over half the default system total of 60. Set the 50 <productname>PostgreSQL</productname> connections. Set the
values you want in your kernel configuration file, e.g.: values you want in your kernel configuration file, e.g.:
<programlisting> <programlisting>
options "SEMMNI=40" options "SEMMNI=40"
...@@ -4427,10 +4457,14 @@ sysctl -w kern.sysv.shmseg ...@@ -4427,10 +4457,14 @@ sysctl -w kern.sysv.shmseg
sysctl -w kern.sysv.shmall sysctl -w kern.sysv.shmall
</programlisting> </programlisting>
In OS X 10.3, these commands have been moved to <filename>/etc/rc</> In OS X 10.3, these commands have been moved to <filename>/etc/rc</>
and must be edited there. Note that <filename>/etc/rc</> is usually and must be edited there. You'll need to reboot to make changes
take effect. Note that <filename>/etc/rc</> is usually
overwritten by OS X updates (such as 10.3.6 to 10.3.7) so you overwritten by OS X updates (such as 10.3.6 to 10.3.7) so you
should expect to have to redo your editing after each update. should expect to have to redo your editing after each update.
</para> </para>
<para>
<varname>SHMALL</> is measured in 4KB pages on this platform.
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -4742,7 +4776,7 @@ sysctl -w vm.overcommit_memory=2 ...@@ -4742,7 +4776,7 @@ sysctl -w vm.overcommit_memory=2
This is the <firstterm>Immediate Shutdown</firstterm>, which This is the <firstterm>Immediate Shutdown</firstterm>, which
will cause the <command>postmaster</command> process to send a will cause the <command>postmaster</command> process to send a
<systemitem>SIGQUIT</systemitem> to all child processes and exit <systemitem>SIGQUIT</systemitem> to all child processes and exit
immediately (without properly shutting itself down). The child processes immediately, without properly shutting itself down. The child processes
likewise exit immediately upon receiving likewise exit immediately upon receiving
<systemitem>SIGQUIT</systemitem>. This will lead to recovery (by <systemitem>SIGQUIT</systemitem>. This will lead to recovery (by
replaying the WAL log) upon next start-up. This is recommended replaying the WAL log) upon next start-up. This is recommended
...@@ -4753,29 +4787,34 @@ sysctl -w vm.overcommit_memory=2 ...@@ -4753,29 +4787,34 @@ sysctl -w vm.overcommit_memory=2
</variablelist> </variablelist>
</para> </para>
<important>
<para> <para>
It is best not to use <systemitem>SIGKILL</systemitem> to shut down The <xref linkend="app-pg-ctl"> program provides a convenient
the server. This will prevent the server from releasing interface for sending these signals to shut down the server.
shared memory and semaphores, which may then have to be done by
manually.
</para> </para>
</important>
<para> <para>
The <acronym>PID</> of the <command>postmaster</command> process can be found using the Alternatively, you can send the signal directly using <command>kill</>.
<command>ps</command> program, or from the file The <acronym>PID</> of the <command>postmaster</command> process can be
<filename>postmaster.pid</filename> in the data directory. So for found using the <command>ps</command> program, or from the file
<filename>postmaster.pid</filename> in the data directory. For
example, to do a fast shutdown: example, to do a fast shutdown:
<screen> <screen>
$ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput> $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput>
</screen> </screen>
</para> </para>
<important>
<para> <para>
The program <command>pg_ctl</command> is a shell script It is best not to use <systemitem>SIGKILL</systemitem> to shut down
that provides a more convenient interface for shutting down the the server. Doing so will prevent the server from releasing
server. shared memory and semaphores, which may then have to be done
manually before a new server can be started. Furthermore,
<systemitem>SIGKILL</systemitem> kills the <command>postmaster</command>
process without letting it relay the signal to its subprocesses,
so it will be necessary to kill the individual subprocesses by hand as
well.
</para> </para>
</important>
</sect1> </sect1>
<sect1 id="ssl-tcp"> <sect1 id="ssl-tcp">
...@@ -4798,10 +4837,11 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput ...@@ -4798,10 +4837,11 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
With <acronym>SSL</> support compiled in, the With <acronym>SSL</> support compiled in, the
<productname>PostgreSQL</> server can be started with <productname>PostgreSQL</> server can be started with
<acronym>SSL</> enabled by setting the parameter <acronym>SSL</> enabled by setting the parameter
<xref linkend="guc-ssl"> to on in <filename>postgresql.conf</>. When <xref linkend="guc-ssl"> to <literal>on</> in
<filename>postgresql.conf</>. When
starting in <acronym>SSL</> mode, the server will look for the starting in <acronym>SSL</> mode, the server will look for the
files <filename>server.key</> and <filename>server.crt</> in the files <filename>server.key</> and <filename>server.crt</> in the
data directory, which should contain the server private key data directory, which must contain the server private key
and certificate, respectively. These files must be set up correctly and certificate, respectively. These files must be set up correctly
before an <acronym>SSL</>-enabled server can start. If the private key is before an <acronym>SSL</>-enabled server can start. If the private key is
protected with a passphrase, the server will prompt for the protected with a passphrase, the server will prompt for the
...@@ -4811,16 +4851,18 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput ...@@ -4811,16 +4851,18 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
<para> <para>
The server will listen for both standard and <acronym>SSL</> The server will listen for both standard and <acronym>SSL</>
connections on the same TCP port, and will negotiate with any connections on the same TCP port, and will negotiate with any
connecting client on whether to use <acronym>SSL</>. See <xref connecting client on whether to use <acronym>SSL</>. By default,
this is at the client's option; see <xref
linkend="auth-pg-hba-conf"> about how to set up the server to linkend="auth-pg-hba-conf"> about how to set up the server to
require use of <acronym>SSL</> for some or all connections. require use of <acronym>SSL</> for some or all connections.
</para> </para>
<para> <para>
For details on how to create your server private key and certificate, For details on how to create your server private key and certificate,
refer to the <productname>OpenSSL</> documentation. A simple refer to the <productname>OpenSSL</> documentation. A
self-signed certificate can be used to get started for testing, but a self-signed certificate can be used for testing, but a
certificate signed by a certificate authority (<acronym>CA</>) (either one of the global certificate signed by a certificate authority (<acronym>CA</>)
(either one of the global
<acronym>CAs</> or a local one) should be used in production so the <acronym>CAs</> or a local one) should be used in production so the
client can verify the server's identity. To create a quick client can verify the server's identity. To create a quick
self-signed certificate, use the following self-signed certificate, use the following
...@@ -4881,7 +4923,8 @@ chmod og-rwx server.key ...@@ -4881,7 +4923,8 @@ chmod og-rwx server.key
One can use <application>SSH</application> to encrypt the network One can use <application>SSH</application> to encrypt the network
connection between clients and a connection between clients and a
<productname>PostgreSQL</productname> server. Done properly, this <productname>PostgreSQL</productname> server. Done properly, this
provides an adequately secure network connection. provides an adequately secure network connection, even for non-SSL-capable
clients.
</para> </para>
<para> <para>
...@@ -4896,7 +4939,7 @@ ssh -L 3333:foo.com:5432 joe@foo.com ...@@ -4896,7 +4939,7 @@ ssh -L 3333:foo.com:5432 joe@foo.com
The first number in the <option>-L</option> argument, 3333, is the The first number in the <option>-L</option> argument, 3333, is the
port number of your end of the tunnel; it can be chosen freely. The port number of your end of the tunnel; it can be chosen freely. The
second number, 5432, is the remote end of the tunnel: the port second number, 5432, is the remote end of the tunnel: the port
number your server is using. The name or the address in between number your server is using. The name or IP address between
the port numbers is the host with the database server you are going the port numbers is the host with the database server you are going
to connect to. In order to connect to the database server using to connect to. In order to connect to the database server using
this tunnel, you connect to port 3333 on the local machine: this tunnel, you connect to port 3333 on the local machine:
...@@ -4905,7 +4948,15 @@ psql -h localhost -p 3333 template1 ...@@ -4905,7 +4948,15 @@ psql -h localhost -p 3333 template1
</programlisting> </programlisting>
To the database server it will then look as though you are really To the database server it will then look as though you are really
user <literal>joe@foo.com</literal> and it will use whatever user <literal>joe@foo.com</literal> and it will use whatever
authentication procedure was set up for this user. In order for the authentication procedure was configured for connections from this
user and host. Note that the server will not think the connection is
SSL-encrypted, since in fact it is not encrypted between the
<application>SSH</application> server and the
<productname>PostgreSQL</productname> server. This should not pose any
extra security risk as long as they are on the same machine.
</para>
<para>
In order for the
tunnel setup to succeed you must be allowed to connect via tunnel setup to succeed you must be allowed to connect via
<command>ssh</command> as <literal>joe@foo.com</literal>, just <command>ssh</command> as <literal>joe@foo.com</literal>, just
as if you had attempted to use <command>ssh</command> to set up a as if you had attempted to use <command>ssh</command> to set up a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment