0

When I am trying to start my PostgreSQL I get the following error in the Postgresql.log file:

FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=5432001, size=41279488, 03600).
HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMMAX.  To reduce the request size (currently 41279488 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
        If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for.
        The PostgreSQL documentation contains more information about shared memory configuration.

So in the etc/sysctl.conf file I have changed the values to

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 52033798400
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 5203379

I restarted the server still I was getting the same error. So I tried this command to reload

sysctl -p 

Then I came up with this error in console

    error: "Read-only file system" setting key "net.ipv4.ip_forward"
error: "Read-only file system" setting key "net.ipv4.conf.default.rp_filter"
error: "Read-only file system" setting key "net.ipv4.conf.default.accept_source_route"
     error: "Read-only file system" setting key "kernel.sysrq"
error: "Read-only file system" setting key "kernel.core_uses_pid"
error: "Read-only file system" setting key "net.ipv4.tcp_syncookies"
error: "Read-only file system" setting key "net.bridge.bridge-nf-call-ip6tables"
error: "Read-only file system" setting key "net.bridge.bridge-nf-call-iptables"
error: "Read-only file system" setting key "net.bridge.bridge-nf-call-arptables"
error: "Read-only file system" setting key "kernel.msgmnb"
error: "Read-only file system" setting key "kernel.msgmax"
error: "Read-only file system" setting key "kernel.shmmax"
error: "Read-only file system" setting key "kernel.shmall"

HOw should I over come this error. What to do to start the Postgres.

1

This page in the manual has detailed instructions how to deal with SHMMAX and SHMALL. It depends on your OS.

For Linux (example from the manual, to allow 16 GB):

$ sysctl -w kernel.shmmax=17179869184
$ sysctl -w kernel.shmall=4194304

Your number is very high: 52033798400 translates to 48 GB. Do you have that much RAM available?

Also, more quotes:

Note that SHMALL is measured in pages rather than bytes on many systems.

And:

A page is almost always 4096 bytes except in unusual kernel configurations with "huge pages" (use getconf PAGE_SIZE to verify).

Bold emphasis mine. You applied a factor 10000 instead. The matching setting for SHMALL would be 12703564 instead of 5203379.

In addition edit the settings in /etc/sysctl.conf to persist the settings for a server restart.
Note that changing this file alone does not affect the running system.

  • A very good answer! – francs Apr 16 '14 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy