AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 320787
Accepted
padjee
padjee
Asked: 2022-12-10 11:10:39 +0800 CST2022-12-10 11:10:39 +0800 CST 2022-12-10 11:10:39 +0800 CST

使用哪个命令重新启动 postgresql 12 服务

  • 772

我即将重启在 Ubuntu 18 上运行的 postgresql 12 服务。首先,我检查它的状态:sudo service postgresql status。它说:

postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor pres
   Active: inactive (dead)
lines 1-3/3 (END)...skipping...
postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

虽然它似乎处于非活动状态,但我仍然可以连接。

然后我运行另一个检查:systemctl status postgresql@12-main。它说 :

root@db-services:/# systemctl status postgresql@12-main
● [email protected] - PostgreSQL Cluster 12-main
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/[email protected]
           └─override.conf
   Active: active (running) since Mon 2022-06-13 09:02:25 WIB; 5 months 27 days ago
 Main PID: 5807 (postgres)
    Tasks: 86 (limit: 4915)
   CGroup: /system.slice/system-postgresql.slice/[email protected]
           ├─ 1586 postgres: 12/main: postgres db_sync 10.100.3.248(61414) idle
           ├─ 1588 postgres: 12/main: postgres db_sync 10.100.3.248(61415) idle
           ├─ 1606 postgres: 12/main: docreg db_docreg 10.100.8.150(18385) idle
           ├─ 1607 postgres: 12/main: docreg db_docreg 10.100.8.150(18399) idle
           ├─ 1608 postgres: 12/main: docreg db_docreg 10.100.8.150(18401) idle
           ├─ 1609 postgres: 12/main: docreg db_docreg 10.100.8.150(18421) idle
           ├─ 2592 postgres: 12/main: docudigtl db_docudigtl 10.100.8.112(34956) idle
           ├─ 3518 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(48290) idle
           ├─ 5150 postgres: 12/main: docudigtl db_docudigtl 10.100.7.114(61504) idle
           ├─ 5807 /usr/lib/postgresql/12/bin/postgres -D /data/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.co
           ├─ 5883 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(48626) idle
           ├─ 6316 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(48704) idle
           ├─ 7049 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(48870) idle
           ├─ 7986 postgres: 12/main: docudigtl db_docudigtl 10.100.7.114(56240) idle
           ├─ 8146 postgres: 12/main: docudigtl db_docudigtl 10.100.8.114(47432) idle
           ├─ 8183 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(49022) idle
           ├─ 8360 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(49036) idle
           ├─ 8445 postgres: 12/main: docudigtl db_docudigtl 10.100.8.114(47478) idle
           ├─ 9590 postgres: 12/main: docudigtl db_docudigtl 10.100.8.106(56094) idle
           ├─ 9687 postgres: 12/main: docudigtl db_docudigtl 10.100.8.112(50980) idle
           ├─10148 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(40646) idle
           ├─10324 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(40680) idle
           ├─11079 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(49496) idle
           ├─11602 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(58152) idle
           ├─11886 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(44674) idle
           ├─12106 postgres: 12/main: docudigtl db_docudigtl 127.0.0.1(49618) idle
           ├─13112 postgres: 12/main: docudigtl db_docudigtl 10.100.6.145(55014) idle
           ├─13122 postgres: 12/main: docudigtl db_docudigtl 10.100.6.145(55015) idle
           ├─13145 postgres: 12/main: docudigtl db_mysapk 10.100.6.145(55016) idle
           ├─13202 postgres: 12/main: docudigtl db_docudigtl 10.100.7.114(62073) idle
           ├─13945 postgres: 12/main: checkpointer
           ├─13946 postgres: 12/main: background writer
           ├─13947 postgres: 12/main: walwriter
           ├─13948 postgres: 12/main: autovacuum launcher
           ├─13949 postgres: 12/main: stats collector
           ├─13950 postgres: 12/main: logical replication launcher

所以它实际上是活跃的!

那我做sudo service --status-all | grep postgresql。它说 :

[ - ]  postgresql
  1. systemctl restart postgresql@12-main VS 有什么区别sudo service postgresql restart?
  2. 我应该使用哪一个来重新启动:systemctl restart postgresql@12-main 或者 sudo service postgresql restart?

为了比较,在另一台服务器上,如果我这样做sudo service postgresql status。它说 :

postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2022-12-05 18:37:03 WIT; 4 days ago
  Process: 22666 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 22666 (code=exited, status=0/SUCCESS)

Dec 05 18:37:03 db-profile-mtr systemd[1]: Starting PostgreSQL RDBMS...
Dec 05 18:37:03 db-profile-mtr systemd[1]: Started PostgreSQL RDBMS.

当我这样做时systemctl status postgresql@12-main,它说:

[email protected] - PostgreSQL Cluster 12-main
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled-runtime; vendor preset: enabled)
   Active: active (running) since Mon 2022-12-05 18:37:03 WIT; 4 days ago
  Process: 22609 ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast 12-main stop (code=exited, status=0/SUCCESS)
  Process: 22631 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 12-main start (code=exited, status=0/SUCCESS)
 Main PID: 22637 (postgres)
    Tasks: 119 (limit: 4915)
   CGroup: /system.slice/system-postgresql.slice/[email protected]
           ├─  417 postgres: 12/main: refer db_ref 10.100.9.50(53216) idle
           ├─  965 postgres: 12/main: refer db_ref 10.100.9.50(53514) idle
           ├─ 1709 postgres: 12/main: profiling db_profile 127.0.0.1(34158) idle
     ...many proceses all the way down

那我做sudo service --status-all | grep postgresql。它说:

 [ + ]  postgresql

需要建议/帮助。谢谢

postgresql
  • 1 1 个回答
  • 37 Views

1 个回答

  • Voted
  1. Best Answer
    Esa Jokinen
    2022-12-10T11:39:17+08:002022-12-10T11:39:17+08:00

    可能两者都不是,因为实际上有两个变量:

    1. 命令。
      • 该service命令是SysVInit遗留下来的。
      • SystemD自带的systemctl,取代了SysVInit;用它。
    2. Ubuntu 上的 Postgresql 服务。
      • postgresql.service控制所有 Postgresql 实例。
      • [email protected]是单个实例;可能有多个。

    重新启动所有实例:sudo systemctl restart postgresql.

    AskUbuntu上有更长的解释。

    • 1

相关问题

  • 我可以在使用数据库后激活 PITR 吗?

  • 运行时间偏移延迟复制的最佳实践

  • 存储过程可以防止 SQL 注入吗?

  • PostgreSQL 中 UniProt 的生物序列

  • PostgreSQL 9.0 Replication 和 Slony-I 有什么区别?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve