@@ -507,11 +507,11 @@ psql: could not connect to server: No such file or directory
507507 <title>Managing Kernel Resources</title>
508508
509509 <para>
510- A large <productname>PostgreSQL</> installation can quickly exhaust
511- various operating system resource limits. (On some systems, the
512- factory defaults are so low that you don't even need a really
513- <quote>large </> installation.) If you have encountered this kind of
514- problem, keep reading .
510+ <productname>PostgreSQL</> can sometimes exhaust various operating system
511+ resource limits, especially when multiple copies of the server are running
512+ on the same system, or in very large installations. This section explains
513+ the kernel resources used by <productname>PostgreSQL </> and the steps you
514+ can take to resolve problems related to kernel resource consumption .
515515 </para>
516516
517517 <sect2 id="sysvipc">
@@ -529,14 +529,11 @@ psql: could not connect to server: No such file or directory
529529 Shared memory and semaphores are collectively referred to as
530530 <quote><systemitem class="osname">System V</>
531531 <acronym>IPC</></quote> (together with message queues, which are not
532- relevant for <productname>PostgreSQL</>). Almost all modern
533- operating systems provide these features, but many of them don't have
534- them turned on or sufficiently sized by default, especially as
535- available RAM and the demands of database applications grow.
536- (On <systemitem class="osname">Windows</>,
537- <productname>PostgreSQL</> provides its own replacement
538- implementation of these facilities, so most of this section
539- can be disregarded.)
532+ relevant for <productname>PostgreSQL</>). Except on
533+ <systemitem class="osname">Windows</>, where <productname>PostgreSQL</>
534+ provides its own replacement implementation of these facilities, these
535+ facilities are required in order to run
536+ <productname>PostgreSQL</>.
540537 </para>
541538
542539 <para>
@@ -558,6 +555,14 @@ psql: could not connect to server: No such file or directory
558555 them, however, vary. Suggestions for some platforms are given below.
559556 </para>
560557
558+ <note>
559+ <para>
560+ Prior to <productname>PostgreSQL</> 9.3, the amount of System V shared
561+ memory required to start the server was much larger. If you are running
562+ an older version of the server, please consult the documentation for
563+ your server version.
564+ </para>
565+ </note>
561566
562567 <table id="sysvipc-parameters">
563568 <title><systemitem class="osname">System V</> <acronym>IPC</> Parameters</title>
@@ -575,7 +580,7 @@ psql: could not connect to server: No such file or directory
575580 <row>
576581 <entry><varname>SHMMAX</></>
577582 <entry>Maximum size of shared memory segment (bytes)</>
578- <entry>at least several megabytes (see text )</entry>
583+ <entry>at least 1kB (more if running many copies of the server )</entry>
579584 </row>
580585
581586 <row>
@@ -636,36 +641,22 @@ psql: could not connect to server: No such file or directory
636641 </tgroup>
637642 </table>
638643
639-
640644 <para>
641- <indexterm><primary>SHMMAX</primary></indexterm> The most important
642- shared memory parameter is <varname>SHMMAX</>, the maximum size, in
643- bytes, of a shared memory segment. If you get an error message from
644- <function>shmget</> like <quote>Invalid argument</>, it is
645- likely that this limit has been exceeded. The size of the required
646- shared memory segment varies depending on several
647- <productname>PostgreSQL</> configuration parameters, as shown in
648- <xref linkend="shared-memory-parameters">. (Any error message you might
649- get will include the exact size of the failed allocation request.)
650- You can, as a temporary solution, lower some of those settings to
651- avoid the failure. While it is possible to get
652- <productname>PostgreSQL</> to run with <varname>SHMMAX</> as small as
653- 2 MB, you need considerably more for acceptable performance. Desirable
654- settings are in the hundreds of megabytes to a few gigabytes.
655- </para>
656-
657- <para>
658- Some systems also have a limit on the total amount of shared memory in
659- the system (<varname>SHMALL</>). Make sure this is large enough
660- for <productname>PostgreSQL</> plus any other applications that
661- are using shared memory segments. Note that <varname>SHMALL</>
662- is measured in pages rather than bytes on many systems.
645+ <productname>PostgreSQL</> requires a few bytes of System V shared memory
646+ (typically 48 bytes, on 64-bit platforms) for each copy of the server.
647+ On most modern operating systems, this amount can easily be allocated.
648+ However, if you are running many copies of the server, or if other
649+ applications are also using System V shared memory, it may be necessary
650+ to increase <varname>SHMMAX</>, the maximum size in bytes of a shared
651+ memory segment, or <varname>SHMALL</>, the total amount of System V shared
652+ memory system-wide. Note that <varname>SHMALL</> is measured in pages
653+ rather than bytes on many systems.
663654 </para>
664655
665656 <para>
666657 Less likely to cause problems is the minimum size for shared
667658 memory segments (<varname>SHMMIN</>), which should be at most
668- approximately 500 kB for <productname>PostgreSQL</> (it is
659+ approximately 32 bytes for <productname>PostgreSQL</> (it is
669660 usually just 1). The maximum number of segments system-wide
670661 (<varname>SHMMNI</>) or per-process (<varname>SHMSEG</>) are unlikely
671662 to cause a problem unless your system has them set to zero.
@@ -747,9 +738,8 @@ psql: could not connect to server: No such file or directory
747738 <indexterm><primary>FreeBSD</><secondary>IPC configuration</></>
748739 <listitem>
749740 <para>
750- The default settings are only suitable for small installations
751- (for example, default <varname>SHMMAX</varname> is 32
752- MB). Changes can be made via the <command>sysctl</command> or
741+ The default settings can be changed using
742+ the <command>sysctl</command> or
753743 <command>loader</command> interfaces. The following
754744 parameters can be set using <command>sysctl</command>:
755745<screen>
@@ -889,14 +879,11 @@ option SEMMAP=256
889879 <indexterm><primary>Linux</><secondary>IPC configuration</></>
890880 <listitem>
891881 <para>
892- The default maximum segment size is 32 MB, which is only adequate
893- for very small <productname>PostgreSQL</productname>
894- installations. The default maximum total size is 2097152
882+ The default maximum segment size is 32 MB, and the
883+ default maximum total size is 2097152
895884 pages. A page is almost always 4096 bytes except in unusual
896885 kernel configurations with <quote>huge pages</quote>
897- (use <literal>getconf PAGE_SIZE</literal> to verify). That
898- makes a default limit of 8 GB, which is often enough, but not
899- always.
886+ (use <literal>getconf PAGE_SIZE</literal> to verify).
900887 </para>
901888
902889 <para>
@@ -1025,8 +1012,7 @@ sysctl -w kern.sysv.shmall
10251012 <indexterm><primary>Solaris</><secondary>IPC configuration</></>
10261013 <listitem>
10271014 <para>
1028- The default maximum size of a shared memory segment is too low for
1029- <productname>PostgreSQL</>. The relevant settings can be changed in
1015+ The relevant settings can be changed in
10301016 <filename>/etc/system</>, for example:
10311017<programlisting>
10321018set shmsys:shminfo_shmmax=0x2000000
@@ -1055,9 +1041,8 @@ set semsys:seminfo_semmsl=32
10551041 In Solaris 10 and OpenSolaris, the default shared memory and
10561042 semaphore settings are good enough for most
10571043 <productname>PostgreSQL</> applications. Solaris now defaults
1058- to a <varname>SHMMAX</> of one-quarter of system <acronym>RAM</>. If
1059- you need to increase this in order to set shared memory settings
1060- slightly higher, you should use a project setting associated
1044+ to a <varname>SHMMAX</> of one-quarter of system <acronym>RAM</>.
1045+ To further adjust this setting, use a project setting associated
10611046 with the <literal>postgres</> user. For example, run the
10621047 following as <literal>root</>:
10631048<programlisting>
@@ -1067,7 +1052,7 @@ projadd -c "PostgreSQL DB User" -K "project.max-shm-memory=(privileged,8GB,deny)
10671052
10681053 <para>
10691054 This command adds the <literal>user.postgres</> project and
1070- raises the shared memory maximum for the <literal>postgres</>
1055+ sets the shared memory maximum for the <literal>postgres</>
10711056 user to 8GB, and takes effect the next time that user logs
10721057 in, or when you restart <productname>PostgreSQL</> (not reload).
10731058 The above assumes that <productname>PostgreSQL</> is run by
@@ -1102,7 +1087,7 @@ project.max-msg-ids=(priv,4096,deny)
11021087 <listitem>
11031088 <para>
11041089 On <productname>UnixWare</> 7, the maximum size for shared
1105- memory segments is only 512 kB in the default configuration.
1090+ memory segments is 512 kB in the default configuration.
11061091 To display the current value of <varname>SHMMAX</>, run:
11071092<programlisting>
11081093/etc/conf/bin/idtune -g SHMMAX
@@ -1126,57 +1111,6 @@ project.max-msg-ids=(priv,4096,deny)
11261111
11271112 </variablelist>
11281113
1129-
1130- <table id="shared-memory-parameters">
1131- <title><productname>PostgreSQL</productname> Shared Memory Usage</>
1132-
1133- <tgroup cols="2">
1134- <thead>
1135- <row>
1136- <entry>Usage</>
1137- <entry>Approximate shared memory bytes required (as of 8.3)</>
1138- </row>
1139- </thead>
1140-
1141- <tbody>
1142- <row>
1143- <entry>Connections</>
1144- <entry>(1800 + 270 * <xref
1145- linkend="guc-max-locks-per-transaction">) * <xref
1146- linkend="guc-max-connections"></entry>
1147- </row>
1148-
1149- <row>
1150- <entry>Autovacuum workers</>
1151- <entry>(1800 + 270 * <xref
1152- linkend="guc-max-locks-per-transaction">) * <xref
1153- linkend="guc-autovacuum-max-workers"></entry>
1154- </row>
1155-
1156- <row>
1157- <entry>Prepared transactions</>
1158- <entry>(770 + 270 * <xref
1159- linkend="guc-max-locks-per-transaction">) * <xref linkend="guc-max-prepared-transactions"></entry>
1160- </row>
1161-
1162- <row>
1163- <entry>Shared disk buffers</>
1164- <entry>(<xref linkend="guc-block-size"> + 208) * <xref linkend="guc-shared-buffers"></entry>
1165- </row>
1166-
1167- <row>
1168- <entry>WAL buffers</>
1169- <entry>(<xref linkend="guc-wal-block-size"> + 8) * <xref linkend="guc-wal-buffers"></entry>
1170- </row>
1171-
1172- <row>
1173- <entry>Fixed space requirements</>
1174- <entry>770 kB</entry>
1175- </row>
1176- </tbody>
1177- </tgroup>
1178- </table>
1179-
11801114 </sect2>
11811115
11821116 <sect2>
0 commit comments