linkend="sysvipc-parameters"> gives an overview. The methods to set
them, however, vary. Suggestions for some platforms are given below.
- Be warned that it is often necessary to reboot your machine, and
- possibly even recompile the kernel, to change these settings.
avoid the failure. While it is possible to get
PostgreSQL> to run with SHMMAX> as small as
2 MB, you need considerably more for acceptable performance. Desirable
- settings are in the tens to hundreds of megabytes.
+ settings are in the hundreds of megabytes to a few gigabytes.
Some systems also have a limit on the total amount of shared memory in
the system (SHMALL>). Make sure this is large enough
for
PostgreSQL> plus any other applications that
- are using shared memory segments. (Caution: SHMALL>
- is measured in pages rather than bytes on many systems.)
+ are using shared memory segments. Note that SHMALL>
+ is measured in pages rather than bytes on many systems.
The default maximum segment size is 32 MB, which is only adequate
- for small
PostgreSQL installations.
- However, the remaining
- defaults are quite generously sized, and usually do not require
- changes. The maximum shared memory segment size can be changed via the
- sysctl interface. For example, to allow 128 MB,
- and explicitly set the maximum total shared memory size to 2097152
- pages (the default):
+ for very small
PostgreSQL
+ installations. The default maximum total size is 2097152
+ pages. A page is almost always 4096 bytes except in unusual
+ kernel configurations with huge pages
+ (use getconf PAGE_SIZE to verify). That
+ makes a default limit of 8 GB, which is often enough, but not
+ always.
+
+
+ The shared memory size settings can be changed via the
+ sysctl interface. For example, to allow 16 GB:
-
$ sysctl -w kernel.shmmax=134217728
-
$ sysctl -w kernel.shmall=2097152
+
$ sysctl -w kernel.shmmax=17179869184
+
$ sysctl -w kernel.shmall=4194304
- In addition these settings can be preserved between reboots in
- the file /etc/sysctl.conf.
+ In addition these settings can be preserved between reboots in
+ the file /etc/sysctl.conf. Doing that is
+ highly recommended.
- Older distributions might not have the sysctl program,
+ Ancient distributions might not have the sysctl program,
but equivalent changes can be made by manipulating the
/proc file system:
-
$ echo 134217728 >/proc/sys/kernel/shmmax
-
$ echo 2097152 >/proc/sys/kernel/shmall
+
$ echo 17179869184 >/proc/sys/kernel/shmmax
+
$ echo 4194304 >/proc/sys/kernel/shmall
+
+ The remaining defaults are quite generously sized, and usually
+ do not require changes.
+