gpt4 book ai didi

postgresql - 无法在 WSL Ubuntu 上启动 postgresql

转载 作者:行者123 更新时间:2023-12-03 18:33:54 25 4
gpt4 key购买 nike

我正在尝试在我的本地机器上启动我的 Postgresql 开发实例。我正在运行带有 WSL Ubuntu 18.04.4 LTS 的 Windows 10 Home(内部版本 18363.900)。我尝试了很多事情:

$ sudo systemctl start postgresql
System has not been booted with systemd as init system (PID 1). Can't operate.
(与重启相同)
$ sudo /etc/init.d/postgresql start
* Starting PostgreSQL 10 database server * 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:
2020-06-16 20:36:37.334 PDT [8106] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2020-06-16 20:36:37.334 PDT [8106] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-06-16 20:36:37.335 PDT [8106] WARNING: could not create listen socket for "localhost"
2020-06-16 20:36:37.335 PDT [8106] FATAL: could not create any TCP/IP sockets
2020-06-16 20:36:37.335 PDT [8106] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.
(postgres 相同)
$ sudo service postgresql start
* Starting PostgreSQL 10 database server * 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:
2020-06-16 20:37:19.907 PDT [8140] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2020-06-16 20:37:19.907 PDT [8140] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-06-16 20:37:19.907 PDT [8140] WARNING: could not create listen socket for "localhost"
2020-06-16 20:37:19.907 PDT [8140] FATAL: could not create any TCP/IP sockets
2020-06-16 20:37:19.908 PDT [8140] LOG: database system is shut down
pg_ctl: could not start server
Examine the log output.
以防万一
$ sudo service postgres start
postgres: unrecognized service
服务没有我好。
停止,当然,按预期工作:
$ sudo service postgresql stop
* Stopping PostgreSQL 10 database server [ OK ]
sudo service postgresql restart
与 start 相同。
状态也给了我一个预期的结果:
$ sudo service postgresql status
10/main (port 5432): down
我的/etc/hosts 读取
# This file is automatically generated by WSL based on the Windows hosts file:
# %WINDIR%\System32\drivers\etc\hosts. Modifications to this file will be overwritten.
127.0.0.1 localhost
127.0.1.1 DESKTOP-LKMEB17.localdomain DESKTOP-LKMEB17

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
这让我相信对/etc/hosts 的更改无济于事
我试图杀死 postmaster,但是每次我尝试杀死它时它的 pid 都在不断变化,这让我相信它在旋转
$ ps -ef | grep postmaster | awk '{print $2}'
8151
$ ps -ef | grep postmaster | awk '{print $2}'
8154
在黑暗中射击以终止进程也不起作用,令人困惑
$ ps -ef | grep postmaster
me 298 116 0 15:35 tty3 00:00:00 grep postmaster
$ kill -9 300
-bash: kill: (300) - No such process
$ kill -9 298
-bash: kill: (298) - No such process
$ kill -9 299
-bash: kill: (299) - No such process
$ kill -9 301
-bash: kill: (301) - No such process
$ ps -ef | grep postmaster
me 300 116 0 15:36 tty3 00:00:00 grep postmaster
这很奇怪——我杀死了 pid 300
令人惊讶的是,似乎没有在 localhost:5432 上收听
$ curl localhost:5432
curl: (52) Empty reply from server
我不知道从这里去哪里。

最佳答案

为什么不能使用 systemd 的答案很简单:WSL 从第一天到现在都不支持它。这是一个已知问题,您可以引用 this issue opened in 2018this issue using a similar configuration of Windows and WSL想要查询更多的信息。
postgresql 的问题是另一个已知问题。它已在 WSL 2 中修复。要在 WSL 1 上解决此问题,this post告诉你设置 fsync=ondata_sync_retry=true .解决问题的另一种方法是设置 fsync=off .引用 this issue有关 WSL 中 fsync 问题的更多信息。

关于postgresql - 无法在 WSL Ubuntu 上启动 postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62421221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com