每当尝试启动时,postgresql
它都会失败。我正在运行 Kali NetHunter。
这是我的终端输出
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!
这是日志文件
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
postgresql
未启动,因为它无法创建足够大的共享内存段,如错误所示:
could not create shared memory segment: Function not implemented
Failed system call was shmget
要修复它,请执行以下操作:
sudo sysctl -w kernel.shmmax=134217728
要在重新启动后永久设置它,请编辑/etc/sysctl.conf
并附加以下内容kernel.shmmax = 134217728
:
sudo vi /etc/sysctl.conf
kernel.shmmax = 134217728
更新答案:
使用OP帮助进行调试:
sudo sysctl -w kernel.shmmax=134217728 sysctl: cannot stat /proc/sys/kernel/shmmax: No such file or directory
综合考虑 Kali NetHunter 适用于 Android 设备,最正确、最明确的答案是shmem
该内核版本中未编译支持。
这也限制了无法运行依赖于shmem
类似Apache
.
唉,在 Android 类设备中运行 postgresql 数据库可能也没有多大意义。
尽管如此,一种可能的做法是尝试找到另一个支持 shmem 的内核包(如果有),或者在极限情况下交叉编译内核。显然,如果您的设备磁盘和/或内存非常低,您不应该考虑这条路线。