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

Commit 005ad6c

Browse files
committed
Add rudimentary section about controlling kernel's file and process limits.
1 parent 745f0c2 commit 005ad6c

File tree

1 file changed

+104
-46
lines changed

1 file changed

+104
-46
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 104 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.45 2000/12/30 15:03:09 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.46 2001/01/08 21:01:54 petere Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -1536,7 +1536,8 @@ options "SEMMNU=120"
15361536

15371537

15381538
<varlistentry>
1539-
<term>FreeBSD</>
1539+
<term>FreeBSD</term>
1540+
<term>OpenBSD</term>
15401541
<listitem>
15411542
<para>
15421543
The options <varname>SYSVSHM</> and <varname>SYSVSEM</> need
@@ -1545,14 +1546,14 @@ options "SEMMNU=120"
15451546
the option <varname>SHMMAXPGS</> (in pages). The following
15461547
shows an example of how to set the various parameters:
15471548
<programlisting>
1548-
options SYSVSHM
1549-
options SHMMAXPGS=4096
1550-
options SHMSEG=256
1551-
1552-
options SYSVSEM
1553-
options SEMMNI=256
1554-
options SEMMNS=512
1555-
options SEMMNU=256
1549+
options SYSVSHM
1550+
options SHMMAXPGS=4096
1551+
options SHMSEG=256
1552+
1553+
options SYSVSEM
1554+
options SEMMNI=256
1555+
options SEMMNS=512
1556+
options SEMMNU=256
15561557
options SEMMAP=256
15571558
</programlisting>
15581559
</para>
@@ -1711,24 +1712,82 @@ set semsys:seminfo_semmsl=32
17111712

17121713
</variablelist>
17131714

1714-
<note>
1715-
<para>
1716-
If your platform is not listed here, please consider
1717-
contributing some information.
1718-
</para>
1719-
</note>
17201715
</para>
17211716
</sect2>
17221717

1723-
<!--
1724-
Other fun things to write about one day:
1725-
* number of processes per user and system-wide (soft/hard limit)
1726-
* open files/inodes per user and system-wide (soft/hard limit)
1727-
(Think about this both ways: Increasing it to allow Postgres to
1728-
open more files, and decreasing it to prevent Postgres from taking
1729-
up all file descriptors.)
1730-
* stack and data segment size, plain-old memory limit
1731-
-->
1718+
1719+
<sect2>
1720+
<title>Resource Limits</title>
1721+
1722+
<para>
1723+
Unix-like operating systems enforce various kinds of resource
1724+
limits that might interfere with the operation of your
1725+
<productname>Postgres</productname> server. Of importance are
1726+
especially the limits on the number of processes per user, the
1727+
number of open files per process, and the amount of memory
1728+
available to a process. Each of these have a <quote>hard</quote>
1729+
and a <quote>soft</quote> limit. The soft limit is what actually
1730+
counts but it can be changed by the user up to the hard limit.
1731+
The hard limit can only be changed by the root user. The system
1732+
call <function>setrlimit</function> is responsible for setting
1733+
these parameters. The shell the built-in command
1734+
<command>ulimit</command> (Bourne shells) or
1735+
<command>limit</command> (csh) is used to control the resource
1736+
limits from the command line. On BSD-derived systems the file
1737+
<filename>/etc/login.conf</filename> controls what values the
1738+
various resource limits are set to upon login. See
1739+
<citerefentry><refentrytitle>login.conf</refentrytitle>
1740+
<manvolnum>5</manvolnum></citerefentry> for details. The relevant
1741+
parameters are <varname>maxproc</varname>,
1742+
<varname>openfiles</varname>, and <varname>datasize</varname>.
1743+
For example:
1744+
<programlisting>
1745+
default:\
1746+
...
1747+
:datasize-cur=256M:\
1748+
:maxproc-cur=256:\
1749+
:openfiles-cur=256:\
1750+
...
1751+
</programlisting>
1752+
(<literal>-cur</literal> is the soft limit. Append
1753+
<literal>-max</literal> to set the hard limit.)
1754+
</para>
1755+
1756+
<para>
1757+
Kernels generally also have an implementation-dependent
1758+
system-wide limit on some resources.
1759+
<simplelist>
1760+
<member>
1761+
On <productname>Linux</productname>
1762+
<filename>/proc/sys/fs/file-max</filename> determines the
1763+
maximum number of files that the kernel will allocate. It can
1764+
be changed by writing a different number into the file or by
1765+
adding an assignment in <filename>/etc/sysctl.conf</filename>.
1766+
The maximum limit of files per process is fixed at the time the
1767+
kernel is compiled; see
1768+
<filename>/usr/src/linux/Documentation/proc.txt</filename> for
1769+
more information.
1770+
</member>
1771+
</simplelist>
1772+
</para>
1773+
1774+
<para>
1775+
The <productname>Postgres</productname> server uses one process
1776+
per connection so you should provide for at least as many processes
1777+
as allowed connections, in addition to what you need for the rest
1778+
of your system. This is usually not a problem but if you run
1779+
several servers on one machine things might get tight.
1780+
</para>
1781+
1782+
<para>
1783+
The factory default limit on open files is often set to
1784+
<quote>socially friendly</quote> values that allow many users to
1785+
coexist on a machine without using an inappropriate fraction of
1786+
the system resources. If you run many servers on a machine this
1787+
is perhaps what you want, but on dedicated servers you may want to
1788+
raise this limit.
1789+
</para>
1790+
</sect2>
17321791

17331792
</sect1>
17341793

@@ -1819,19 +1878,18 @@ set semsys:seminfo_semmsl=32
18191878
can be started with the argument <option>-l</> (ell) to enable
18201879
SSL connections. When starting in SSL mode, the postmaster will look
18211880
for the files <filename>server.key</> and <filename>server.crt</> in
1822-
the data directory (pointed to by <envar>PGDATA</envar>).
1823-
These files should contain the server private key
1881+
the data directory. These files should contain the server private key
18241882
and certificate respectively. These files must be set up correctly
18251883
before an SSL-enabled server can start. If the private key is protected
18261884
with a passphrase, the postmaster will prompt for the passphrase and will
1827-
not start until it has been provided.
1885+
not start until it has been entered.
18281886
</para>
18291887

18301888
<para>
18311889
The postmaster will listen for both standard and SSL connections
18321890
on the same TCP/IP port, and will negotiate with any connecting
18331891
client whether or not to use SSL.
1834-
See <xref linkend="client-authentication">
1892+
See <xref linkend="client-authentication">
18351893
about how to force on the server side the use of SSL for certain
18361894
connections.
18371895
</para>
@@ -1843,27 +1901,27 @@ set semsys:seminfo_semmsl=32
18431901
by a CA (either one of the global CAs or a local one) should be used in
18441902
production so the client can verify the servers identity. To create
18451903
a quick self-signed certificate, use the following OpenSSL command:
1846-
<programlisting>
1847-
openssl req -new -text -out cert.req
1848-
</programlisting>
1904+
<programlisting>
1905+
openssl req -new -text -out cert.req
1906+
</programlisting>
18491907
Fill out the information that openssl asks for. Make sure that you enter
18501908
the local host name as Common Name; the challenge password can be
1851-
left blank. The script will generate a key that is passphrase protected;
1852-
it will not accept a pass phrase that is less than four characters long.
1853-
To remove the passphrase (as you must if you want automatic start-up of
1854-
the postmaster), run the commands
1855-
<programlisting>
1856-
mv privkey.pem cert.pem.pw
1857-
openssl rsa -in cert.pem.pw -out cert.pem
1858-
</programlisting>
1909+
left blank. The script will generate a key that is passphrase protected;
1910+
it will not accept a pass phrase that is less than four characters long.
1911+
To remove the passphrase (as you must if you want automatic start-up of
1912+
the postmaster), run the commands
1913+
<programlisting>
1914+
mv privkey.pem cert.pem.pw
1915+
openssl rsa -in cert.pem.pw -out cert.pem
1916+
</programlisting>
18591917
Enter the old passphrase to unlock the existing key. Now do
1860-
<programlisting>
1861-
openssl req -x509 -in cert.req -text -key cert.pem -out cert.cert
1862-
cp cert.pem $PGDATA/server.key
1863-
cp cert.cert $PGDATA/server.crt
1864-
</programlisting>
1918+
<programlisting>
1919+
openssl req -x509 -in cert.req -text -key cert.pem -out cert.cert
1920+
cp cert.pem <replaceable>$PGDATA</replaceable>/server.key
1921+
cp cert.cert <replaceable>$PGDATA</replaceable>/server.crt
1922+
</programlisting>
18651923
to turn the certificate into a self-signed certificate and to copy the
1866-
key and certificate to where the postmaster will look for them.
1924+
key and certificate to where the postmaster will look for them.
18671925
</para>
18681926
</sect1>
18691927

0 commit comments

Comments
 (0)