@@ -507,11 +507,11 @@ psql: could not connect to server: No such file or directory
507
507
<title>Managing Kernel Resources</title>
508
508
509
509
<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 .
515
515
</para>
516
516
517
517
<sect2 id="sysvipc">
@@ -529,14 +529,11 @@ psql: could not connect to server: No such file or directory
529
529
Shared memory and semaphores are collectively referred to as
530
530
<quote><systemitem class="osname">System V</>
531
531
<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</>.
540
537
</para>
541
538
542
539
<para>
@@ -558,6 +555,14 @@ psql: could not connect to server: No such file or directory
558
555
them, however, vary. Suggestions for some platforms are given below.
559
556
</para>
560
557
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>
561
566
562
567
<table id="sysvipc-parameters">
563
568
<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
575
580
<row>
576
581
<entry><varname>SHMMAX</></>
577
582
<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>
579
584
</row>
580
585
581
586
<row>
@@ -636,36 +641,22 @@ psql: could not connect to server: No such file or directory
636
641
</tgroup>
637
642
</table>
638
643
639
-
640
644
<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.
663
654
</para>
664
655
665
656
<para>
666
657
Less likely to cause problems is the minimum size for shared
667
658
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
669
660
usually just 1). The maximum number of segments system-wide
670
661
(<varname>SHMMNI</>) or per-process (<varname>SHMSEG</>) are unlikely
671
662
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
747
738
<indexterm><primary>FreeBSD</><secondary>IPC configuration</></>
748
739
<listitem>
749
740
<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
753
743
<command>loader</command> interfaces. The following
754
744
parameters can be set using <command>sysctl</command>:
755
745
<screen>
@@ -889,14 +879,11 @@ option SEMMAP=256
889
879
<indexterm><primary>Linux</><secondary>IPC configuration</></>
890
880
<listitem>
891
881
<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
895
884
pages. A page is almost always 4096 bytes except in unusual
896
885
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).
900
887
</para>
901
888
902
889
<para>
@@ -1025,8 +1012,7 @@ sysctl -w kern.sysv.shmall
1025
1012
<indexterm><primary>Solaris</><secondary>IPC configuration</></>
1026
1013
<listitem>
1027
1014
<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
1030
1016
<filename>/etc/system</>, for example:
1031
1017
<programlisting>
1032
1018
set shmsys:shminfo_shmmax=0x2000000
@@ -1055,9 +1041,8 @@ set semsys:seminfo_semmsl=32
1055
1041
In Solaris 10 and OpenSolaris, the default shared memory and
1056
1042
semaphore settings are good enough for most
1057
1043
<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
1061
1046
with the <literal>postgres</> user. For example, run the
1062
1047
following as <literal>root</>:
1063
1048
<programlisting>
@@ -1067,7 +1052,7 @@ projadd -c "PostgreSQL DB User" -K "project.max-shm-memory=(privileged,8GB,deny)
1067
1052
1068
1053
<para>
1069
1054
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</>
1071
1056
user to 8GB, and takes effect the next time that user logs
1072
1057
in, or when you restart <productname>PostgreSQL</> (not reload).
1073
1058
The above assumes that <productname>PostgreSQL</> is run by
@@ -1102,7 +1087,7 @@ project.max-msg-ids=(priv,4096,deny)
1102
1087
<listitem>
1103
1088
<para>
1104
1089
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.
1106
1091
To display the current value of <varname>SHMMAX</>, run:
1107
1092
<programlisting>
1108
1093
/etc/conf/bin/idtune -g SHMMAX
@@ -1126,57 +1111,6 @@ project.max-msg-ids=(priv,4096,deny)
1126
1111
1127
1112
</variablelist>
1128
1113
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
-
1180
1114
</sect2>
1181
1115
1182
1116
<sect2>
0 commit comments