0

Whenever trying to start postgresql however it fails. I am running Kali NetHunter.

Here's my terminal output

root@kali:~# service postgresql start
[....] Starting PostgreSQL 10 database server: main[....] Error: /usr/lib/postgresql/10/bin/pg_ctl /usr/lib/postgresql/10/bin/pg_ctl start -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-10-main.log -s -o -c config_file="/etc/postgresql/10/main/postgresql.conf" exited with status 1: 2018-02-07 09:29:59.653 UTC 0 LOG: listening on IPv6 address "::1", port 5432 2018-02-07 09:29:59.653 UTC 0 LOG: listening on IPv4 address "127.0.0.1", port 5432 2018-02-07 09:29:59.654 UTC 0 LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2018-02-07 09:29:59.656 UTC 0 FATAL: could not create shared memory segment: Function not implemented 2018-02-07 09:29:59.656 UTC 0 DETAIL: Failed system call was shmget(key=5432001, size=40, 03600). 2018-02-07 09:29:59.656 UTC 0 LOG: database system is shut down pg_ctl: could not start [FAILr Examine the log output. ... failed!
 failed!

And here's the log file

2018-02-06 16:31:36.775 UTC [6358] LOG:  listening on IPv6 address "::1", port 5432
2018-02-06 16:31:36.775 UTC [6358] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-06 16:31:36.783 UTC [6358] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-06 16:31:36.785 UTC [6358] FATAL:  could not create shared memory segment: Function not implemented
2018-02-06 16:31:36.785 UTC [6358] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-06 16:31:36.785 UTC [6358] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2018-02-06 16:57:52.984 UTC [8837] LOG:  listening on IPv6 address "::1", port 5432
2018-02-06 16:57:52.984 UTC [8837] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-06 16:57:52.985 UTC [8837] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-06 16:57:52.988 UTC [8837] FATAL:  could not create shared memory segment: Function not implemented
2018-02-06 16:57:52.988 UTC [8837] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-06 16:57:52.988 UTC [8837] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2018-02-06 16:57:53.693 UTC [8875] LOG:  listening on IPv6 address "::1", port 5432
2018-02-06 16:57:53.693 UTC [8875] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-06 16:57:53.694 UTC [8875] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-06 16:57:53.695 UTC [8875] FATAL:  could not create shared memory segment: Function not implemented
2018-02-06 16:57:53.695 UTC [8875] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-06 16:57:53.696 UTC [8875] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2018-02-07 02:57:25.787 UTC [15672] LOG:  listening on IPv6 address "::1", port 5432
2018-02-07 02:57:25.788 UTC [15672] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-07 02:57:25.788 UTC [15672] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-07 02:57:25.790 UTC [15672] FATAL:  could not create shared memory segment: Function not implemented
2018-02-07 02:57:25.790 UTC [15672] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-07 02:57:25.791 UTC [15672] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2018-02-07 03:13:39.986 UTC [17336] LOG:  listening on IPv6 address "::1", port 5432
2018-02-07 03:13:39.987 UTC [17336] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-07 03:13:39.988 UTC [17336] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-07 03:13:39.989 UTC [17336] FATAL:  could not create shared memory segment: Function not implemented
2018-02-07 03:13:39.989 UTC [17336] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-07 03:13:39.989 UTC [17336] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2018-02-07 06:26:52.218 UTC [32350] LOG:  listening on IPv6 address "::1", port 5432
2018-02-07 06:26:52.219 UTC [32350] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-07 06:26:52.219 UTC [32350] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-07 06:26:52.221 UTC [32350] FATAL:  could not create shared memory segment: Function not implemented
2018-02-07 06:26:52.221 UTC [32350] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-07 06:26:52.222 UTC [32350] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2018-02-07 09:29:59.653 UTC [10136] LOG:  listening on IPv6 address "::1", port 5432
2018-02-07 09:29:59.653 UTC [10136] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2018-02-07 09:29:59.654 UTC [10136] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-02-07 09:29:59.656 UTC [10136] FATAL:  could not create shared memory segment: Function not implemented
2018-02-07 09:29:59.656 UTC [10136] DETAIL:  Failed system call was shmget(key=5432001, size=40, 03600).
2018-02-07 09:29:59.656 UTC [10136] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.

1 Answer 1

4

postgresql is not up because it cannot create a big enough shared memory segment as seen by the error:

could not create shared memory segment: Function not implemented
Failed system call was shmget

To fix it, do:

sudo sysctl -w kernel.shmmax=134217728

For setting it permanently after reboots, edit /etc/sysctl.conf and append to it the kernel.shmmax = 134217728:

sudo vi /etc/sysctl.conf
kernel.shmmax = 134217728

UPDATE to the answer:

Debugging it with the OP help:

sudo sysctl -w kernel.shmmax=134217728 sysctl: cannot stat /proc/sys/kernel/shmmax: No such file or directory

That joined together that Kali NetHunter is for Android devices, the most correct and definitive answer is that shmemsupport was not compiled in this kernel version.

That also limits on not being able to run other software reliant on having shmem like Apache.

Alas, it also may not make much sense running a postgresql DB in an Android-class devices.

Nevertheless, a possible course of action is either trying to find another kernel package (if there is one), that support shmem, or at limit cross-compile a kernel. Obviously, you should not consider this route is your device is very low in disk and/or memory.

3
  • Actually I've tried it but it says sysctl: cannot stat /proc/sys/kernel/shmmax: No such file or directory
    – Mr. Robot
    Commented Feb 7, 2018 at 10:57
  • Here's the complete terminal output. root@kali:~# sudo sysctl -w kernel.shmmax=134217728 sysctl: cannot stat /proc/sys/kernel/shmmax: No such file or directory root@kali:~#
    – Mr. Robot
    Commented Feb 7, 2018 at 11:02
  • @KrishnaDeshpandeKD Linux in Android. The kernel is probably compiled without support for shmem. No dice. Commented Feb 7, 2018 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .