CentOS 7下如何重启PostgreSQL服务器

Séb*_*ent 21 postgresql centos-7 pg-hba.conf

我在 CentOS 7.3 环境下安装了 PostgreSQL 10.1。

服务已启动(postmaster.pid文件存在于 下/var/lib/pgsql/10/data),但我需要在pg_hba.conf.

但是,尝试不同的命令,我得到以下信息:

pg_ctl reload -D /var/lib/pgsql/10/data
bash: pg_ctl: command not found

service postgresql reload
Redirecting to /bin/systemctl reload postgresql.service
Failed to reload postgresql.service: Unit not found.
Run Code Online (Sandbox Code Playgroud)

Séb*_*ent 44

我发现您需要指定PostgreSQL 服务的确切名称,您可以在服务列表下找到该名称,使用systemctl(另见这篇文章):

systemctl list-units|grep postgresql
postgresql-10.service                                                                     loaded active running   PostgreSQL 10 database server
Run Code Online (Sandbox Code Playgroud)

然后你可以使用service

service postgresql-10.service reload
Run Code Online (Sandbox Code Playgroud)

或者

service postgresql-10.service restart
Run Code Online (Sandbox Code Playgroud)

或者,您可以使用以下systemctl命令:

/bin/systemctl reload postgresql-10.service
Run Code Online (Sandbox Code Playgroud)

或者

/bin/systemctl restart postgresql-10.service
Run Code Online (Sandbox Code Playgroud)


usr*_*usr 5

如果你有 sudogoer 作为 postgresql 中的角色,你也可以使用:

sudo systemctl restart postgresql
Run Code Online (Sandbox Code Playgroud)

  • 这是错误的,单位叫做`postgresql-10` (2认同)