为什么同时有 postmaster 和 postgres 可执行文件?

Don*_*ato 8 postgresql

有点令人困惑的是如何使用多个可执行文件来启动 postgresql,例如 postmaster、postgres、pg_ctl。

postmaster -D /usr/local/pgsql/data
postgres -D /usr/local/pgsql/data
pg_ctl -D /usr/local/pgsql/data
Run Code Online (Sandbox Code Playgroud)

我知道 pg_ctl 旨在简化启动 postgres 的过程,但 postmaster 和 postgres 似乎是相同的二进制文件。看来 postmaster 是 postgres 的符号链接。这样做有什么好处呢?

Cra*_*ger 10

postmaster符号链接似乎是历史性的。在你指出之前我什至不知道它的存在。

另外两个是 UNIX 守护程序应用程序的典型模式。postgres提供服务器功能,并pg_ctl为其提供控制客户端。

可以将pg_ctl的功能捆绑到 中postgres,但这样做意味着postgres必须以两种模式运行:作为数据库服务器,或作为连接到正在运行的数据库服务器的客户端。这在架构上有点令人不快,并且会向正在运行的 PostgreSQL 服务器实例添加本质上“死代码”(无法访问且无法使用)的内容。

同样,可以删除从postgres可执行文件启动 PostgreSQL 服务器的功能,并要求您通过 来执行此操作pg_ctl,但这会很麻烦,并且会真正惹恼管理发行版初始化脚本的人。他们通常希望绕过应用程序启动程序并直接启动守护进程,这样他们就可以阻止它分离以在后台运行、捕获退出代码、捕获stderr等。

本质上:postgres是低级服务器程序。pg_ctl是用于启动/停止服务器和其他管理操作的用户工具。postmaster是 的过时别名postgres

通常,如果您从软件包安装 PostgreSQL,或者从不与操作系统服务系统集成的源或第 3 方二进制安装程序安装,则可以使用分发服务管理( servicesystemctlupdate-rc.d等) 。pg_ctl