postgresql 没有在 WSL 上启动?

Eri*_*met 3 postgresql windows-subsystem-for-linux

两周前,我在适用于 Linux 的 Windows 子系统中安装了 Ubuntu 18.04。

在那里,我使用以下命令安装了 PostgreSQL 11:

sudo apt-get install postgresql-11
Run Code Online (Sandbox Code Playgroud)

当时,我可以使用以下命令启动我的 PostgreSQL:

sudo -u postgres /usr/lib/postgresql/11/bin/pg_ctl -D /etc/postgresql/11/main -l /var/log/postgresql/postgresql-11-main.log start
Run Code Online (Sandbox Code Playgroud)

到现在为止还挺好。

两周后,我尝试使用相同的命令启动这个 PostgreSQL 引擎,但出现此错误:

"FATAL:  could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory"
Run Code Online (Sandbox Code Playgroud)

我创建了该文件夹并将其提供给它chmod 777以避免权限问题。

然后我得到:

LOG:  database system was interrupted; last known up at 2019-02-16 17:57:02 STD
PANIC:  could not flush dirty data: Function not implemented
LOG:  startup process (PID 94) was terminated by signal 6: Aborted
Run Code Online (Sandbox Code Playgroud)

知道可能有什么问题吗?

Dan*_*ité 5

PostgreSQL 中最近发生fsync了一些与 Windows Linux 子系统有关的变化。PANIC您提到的具体错误目前在 PG 邮件列表中进行了讨论,并提供了一个补丁:

WSL(Linux 上的 Windows 子系统)用户需要从 11.2 开始关闭 fsync

请注意,主题中建议的变通方法fsync是关闭,不适用于生产用途。如果您在 WSL 上使用 Postgres,并且并不真正关心数据的持久性,那也没关系。有人说 WSL 本身无论如何都不用于生产用途。

/var/run/postgresql不存在的事实是完全不相关的。 /var/run通常安装在 RAM 磁盘上,并由您使用手动启动程序回避的启动脚本创建。典型的正常程序类似于systemctl start postgresql,它在一切配置正常时工作,并负责使用适当的权限创建此目录。