W
W
wittyrider2015-09-04 05:41:09
linux
wittyrider, 2015-09-04 05:41:09

PostgreSQL initialization error(could not create shared memory segment)?

Installed PostgreSQL but can't run. Sees this error:

~❯❯❯ su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgres/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /var/lib/postgres/data/base/1 ... FATAL:  could not create shared memory segment: No space left on device
DETAIL:  Failed system call was shmget(key=1, size=56, 03600).
HINT:  This error does *not* mean that you have run out of disk space.  It occurs either if all available shared memory IDs have been taken, in which case you need to raise the SHMMNI parameter in your kernel, or because the system's overall limit for shared memory has been reached.
  The PostgreSQL documentation contains more information about shared memory configuration.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgres/data"
~❯❯❯

The documentation suggests changing the kernel parameters. did not help.
Information:
~❯❯❯ sysctl -a | grep kernel.shm                                               
kernel.shm_rmid_forced = 0
kernel.shmall = 524288
kernel.shmmax = 2147483648
kernel.shmmni = 4096
~❯❯❯ uname -a
Linux cold 4.1.6-1-ARCH #1 SMP PREEMPT Mon Aug 17 08:52:28 CEST 2015 x86_64 GNU/Linux
~❯❯❯ postgres -V
postgres (PostgreSQL) 9.4.4
~❯❯❯ free
              total        used        free      shared  buff/cache   available
Mem:        4005496     2419924      154676      131556     1430896     1392468
Swap:             0           0           0
~❯❯❯ getconf PAGE_SIZE
4096
~❯❯❯

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadz Goldman, 2015-09-04
@nadz

Either increase:
sudo sysctl -w kernel.shmmax=21474836488
Or decrease:
sudo sysctl -w kernel.shmmax=21474836
Depends on your settings: how much memory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question