当前位置: 首页 > news >正文

PostgreSQL 三种关库模式

PostgreSQL 三种关库模式

基础信息
OS版本:Red Hat Enterprise Linux Server release 7.9 (Maipo)
DB版本:16.2
pg软件目录:/home/pg16/soft
pg数据目录:/home/pg16/data
端口:5777

PostgreSQL 提供了三种关库模式,分别是 Smart ShutdownFast ShutdownImmediate Shutdown。以下是每种模式的详细说明:

  1. Smart Shutdown
    • 这种模式下,数据库会等待所有活跃的客户端连接断开后才会停止。
    • 如果用户一直不断开连接,服务器将无法停止。
    • 使用 pg_ctl 命令的示例如下:
      pg_ctl stop -m smart
      

输出日志

2024-11-27 06:01:14.149 PST [127700] DEBUG:  postmaster received shutdown request signal
2024-11-27 06:01:14.149 PST [127700] LOG:  received smart shutdown request
2024-11-27 06:01:14.150 PST [127700] DEBUG:  sending signal 15 to process 127708
2024-11-27 06:01:14.150 PST [127708] DEBUG:  logical replication launcher shutting down
2024-11-27 06:01:14.150 PST [127706] DEBUG:  autovacuum launcher shutting down
2024-11-27 06:01:14.150 PST [127708] DEBUG:  shmem_exit(1): 5 before_shmem_exit callbacks to make
2024-11-27 06:01:14.150 PST [127706] DEBUG:  shmem_exit(0): 4 before_shmem_exit callbacks to make
2024-11-27 06:01:14.150 PST [127708] DEBUG:  shmem_exit(1): 6 on_shmem_exit callbacks to make
2024-11-27 06:01:14.150 PST [127708] DEBUG:  proc_exit(1): 1 callbacks to make
2024-11-27 06:01:14.150 PST [127708] DEBUG:  exit(1)
2024-11-27 06:01:14.150 PST [127708] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.150 PST [127708] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.150 PST [127708] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.150 PST [127705] DEBUG:  shmem_exit(0): 4 before_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127705] DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127705] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:01:14.151 PST [127705] DEBUG:  exit(0)
2024-11-27 06:01:14.151 PST [127705] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127705] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127705] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.151 PST [127706] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127706] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:01:14.151 PST [127706] DEBUG:  exit(0)
2024-11-27 06:01:14.151 PST [127706] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127706] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127706] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.151 PST [127700] DEBUG:  reaping dead processes
2024-11-27 06:01:14.151 PST [127700] LOG:  background worker "logical replication launcher" (PID 127708) exited with exit code 1
2024-11-27 06:01:14.151 PST [127703] DEBUG:  shmem_exit(0): 4 before_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127703] DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127703] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:01:14.151 PST [127703] DEBUG:  exit(0)
2024-11-27 06:01:14.151 PST [127703] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127703] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.151 PST [127703] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.151 PST [127700] DEBUG:  reaping dead processes
2024-11-27 06:01:14.152 PST [127700] DEBUG:  reaping dead processes
2024-11-27 06:01:14.152 PST [127702] LOG:  shutting down
2024-11-27 06:01:14.178 PST [127707] DEBUG:  executing archive command "test ! -f /home/pg16/archivelog/00000001000000040000002F && cp pg_wal/00000001000000040000002F /home/pg16/archivelog/00000001000000040000002F"
2024-11-27 06:01:14.178 PST [127702] LOG:  checkpoint starting: shutdown immediate
2024-11-27 06:01:14.178 PST [127702] DEBUG:  performing replication slot checkpoint
2024-11-27 06:01:14.181 PST [127702] DEBUG:  attempting to remove WAL segments older than log file 00000000000000040000002F
2024-11-27 06:01:14.182 PST [127702] DEBUG:  SlruScanDirectory invoking callback on pg_subtrans/005C
2024-11-27 06:01:14.182 PST [127702] LOG:  checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.004 s; sync files=0, longest=0.000 s, average=0.000 s; distance=16383 kB, estimate=16383 kB; lsn=4/30000028, redo lsn=4/30000028
2024-11-27 06:01:14.182 PST [127702] DEBUG:  shmem_exit(0): 5 before_shmem_exit callbacks to make
2024-11-27 06:01:14.182 PST [127702] DEBUG:  writing stats file "pg_stat/pgstat.stat"
2024-11-27 06:01:14.182 PST [127702] DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make
2024-11-27 06:01:14.182 PST [127702] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:01:14.182 PST [127702] DEBUG:  exit(0)
2024-11-27 06:01:14.182 PST [127702] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.182 PST [127702] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.182 PST [127702] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.183 PST [127700] DEBUG:  reaping dead processes
2024-11-27 06:01:14.196 PST [127707] DEBUG:  archived write-ahead log file "00000001000000040000002F"
2024-11-27 06:01:14.197 PST [127707] DEBUG:  shmem_exit(0): 5 before_shmem_exit callbacks to make
2024-11-27 06:01:14.197 PST [127707] DEBUG:  archiver process shutting down
2024-11-27 06:01:14.197 PST [127707] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 06:01:14.197 PST [127707] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:01:14.197 PST [127707] DEBUG:  exit(0)
2024-11-27 06:01:14.197 PST [127707] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.197 PST [127707] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.197 PST [127707] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.202 PST [127700] DEBUG:  reaping dead processes
2024-11-27 06:01:14.202 PST [127700] DEBUG:  shmem_exit(0): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.202 PST [127700] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 06:01:14.205 PST [127700] DEBUG:  cleaning up orphaned dynamic shared memory with ID 210471318
2024-11-27 06:01:14.205 PST [127700] DEBUG:  cleaning up dynamic shared memory control segment with ID 4077101978
2024-11-27 06:01:14.205 PST [127700] DEBUG:  proc_exit(0): 2 callbacks to make
2024-11-27 06:01:14.206 PST [127700] LOG:  database system is shut down
2024-11-27 06:01:14.206 PST [127700] DEBUG:  exit(0)
2024-11-27 06:01:14.206 PST [127700] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.206 PST [127700] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.206 PST [127700] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:01:14.207 PST [127701] DEBUG:  logger shutting down
2024-11-27 06:01:14.207 PST [127701] DEBUG:  shmem_exit(0): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.207 PST [127701] DEBUG:  shmem_exit(0): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.207 PST [127701] DEBUG:  proc_exit(0): 0 callbacks to make
2024-11-27 06:01:14.207 PST [127701] DEBUG:  exit(0)
2024-11-27 06:01:14.207 PST [127701] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:01:14.208 PST [127701] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:01:14.208 PST [127701] DEBUG:  proc_exit(-1): 0 callbacks to make
  1. Fast Shutdown(默认方式)
    • 快速关闭模式,不再允许新的连接。
    • 向所有活跃的服务进程发送 SIGTERM 信号,让它们立即退出,然后等待所有子进程退出并关闭数据库。
    • 如果服务处于在线备份状态,将直接终止备份,这将导致此次备份失败。
    • 使用 pg_ctl 命令的示例如下:
      pg_ctl stop -m fast
      

输出日志

2024-11-27 06:02:17.051 PST [127815] DEBUG:  postmaster received shutdown request signal
2024-11-27 06:02:17.051 PST [127815] LOG:  received fast shutdown request
2024-11-27 06:02:17.052 PST [127815] LOG:  aborting any active transactions
2024-11-27 06:02:17.052 PST [127815] DEBUG:  sending signal 15 to process 127823
2024-11-27 06:02:17.052 PST [127818] DEBUG:  shmem_exit(0): 4 before_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  autovacuum launcher shutting down
2024-11-27 06:02:17.052 PST [127818] DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  shmem_exit(0): 4 before_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127818] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:02:17.052 PST [127818] DEBUG:  exit(0)
2024-11-27 06:02:17.052 PST [127818] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127818] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127818] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  exit(0)
2024-11-27 06:02:17.052 PST [127821] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.052 PST [127821] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.053 PST [127823] DEBUG:  logical replication launcher shutting down
2024-11-27 06:02:17.053 PST [127823] DEBUG:  shmem_exit(1): 5 before_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127823] DEBUG:  shmem_exit(1): 6 on_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127823] DEBUG:  proc_exit(1): 1 callbacks to make
2024-11-27 06:02:17.053 PST [127823] DEBUG:  exit(1)
2024-11-27 06:02:17.053 PST [127823] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127823] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127823] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.053 PST [127820] DEBUG:  shmem_exit(0): 4 before_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127815] DEBUG:  reaping dead processes
2024-11-27 06:02:17.053 PST [127820] DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127820] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:02:17.053 PST [127820] DEBUG:  exit(0)
2024-11-27 06:02:17.053 PST [127820] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127820] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.053 PST [127820] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.053 PST [127815] DEBUG:  reaping dead processes
2024-11-27 06:02:17.053 PST [127815] LOG:  background worker "logical replication launcher" (PID 127823) exited with exit code 1
2024-11-27 06:02:17.053 PST [127815] DEBUG:  reaping dead processes
2024-11-27 06:02:17.053 PST [127817] LOG:  shutting down
2024-11-27 06:02:17.086 PST [127822] DEBUG:  executing archive command "test ! -f /home/pg16/archivelog/000000010000000400000030 && cp pg_wal/000000010000000400000030 /home/pg16/archivelog/000000010000000400000030"
2024-11-27 06:02:17.086 PST [127817] LOG:  checkpoint starting: shutdown immediate
2024-11-27 06:02:17.087 PST [127817] DEBUG:  performing replication slot checkpoint
2024-11-27 06:02:17.089 PST [127817] DEBUG:  checkpoint sync: number=1 file=pg_xact/0005 time=0.618 ms
2024-11-27 06:02:17.090 PST [127817] DEBUG:  checkpoint sync: number=2 file=pg_multixact/offsets/0000 time=0.175 ms
2024-11-27 06:02:17.090 PST [127817] DEBUG:  attempting to remove WAL segments older than log file 000000000000000400000030
2024-11-27 06:02:17.090 PST [127817] DEBUG:  removing write-ahead log file "00000001000000040000002F"
2024-11-27 06:02:17.093 PST [127817] DEBUG:  SlruScanDirectory invoking callback on pg_subtrans/005C
2024-11-27 06:02:17.093 PST [127817] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 1 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.008 s; sync files=2, longest=0.001 s, average=0.001 s; distance=16384 kB, estimate=16384 kB; lsn=4/31000028, redo lsn=4/31000028
2024-11-27 06:02:17.093 PST [127817] DEBUG:  shmem_exit(0): 5 before_shmem_exit callbacks to make
2024-11-27 06:02:17.093 PST [127817] DEBUG:  writing stats file "pg_stat/pgstat.stat"
2024-11-27 06:02:17.093 PST [127817] DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make
2024-11-27 06:02:17.093 PST [127817] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:02:17.093 PST [127817] DEBUG:  exit(0)
2024-11-27 06:02:17.094 PST [127817] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.094 PST [127817] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.094 PST [127817] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.095 PST [127815] DEBUG:  reaping dead processes
2024-11-27 06:02:17.102 PST [127822] DEBUG:  archived write-ahead log file "000000010000000400000030"
2024-11-27 06:02:17.102 PST [127822] DEBUG:  shmem_exit(0): 5 before_shmem_exit callbacks to make
2024-11-27 06:02:17.102 PST [127822] DEBUG:  archiver process shutting down
2024-11-27 06:02:17.102 PST [127822] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 06:02:17.102 PST [127822] DEBUG:  proc_exit(0): 1 callbacks to make
2024-11-27 06:02:17.102 PST [127822] DEBUG:  exit(0)
2024-11-27 06:02:17.102 PST [127822] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.102 PST [127822] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.102 PST [127822] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.102 PST [127815] DEBUG:  reaping dead processes
2024-11-27 06:02:17.102 PST [127815] DEBUG:  shmem_exit(0): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.103 PST [127815] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 06:02:17.105 PST [127815] DEBUG:  cleaning up orphaned dynamic shared memory with ID 2186499264
2024-11-27 06:02:17.106 PST [127815] DEBUG:  cleaning up dynamic shared memory control segment with ID 3559701182
2024-11-27 06:02:17.106 PST [127815] DEBUG:  proc_exit(0): 2 callbacks to make
2024-11-27 06:02:17.106 PST [127815] LOG:  database system is shut down
2024-11-27 06:02:17.106 PST [127815] DEBUG:  exit(0)
2024-11-27 06:02:17.106 PST [127815] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.106 PST [127815] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.106 PST [127815] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 06:02:17.106 PST [127816] DEBUG:  logger shutting down
2024-11-27 06:02:17.107 PST [127816] DEBUG:  shmem_exit(0): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.107 PST [127816] DEBUG:  shmem_exit(0): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.107 PST [127816] DEBUG:  proc_exit(0): 0 callbacks to make
2024-11-27 06:02:17.107 PST [127816] DEBUG:  exit(0)
2024-11-27 06:02:17.107 PST [127816] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 06:02:17.107 PST [127816] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 06:02:17.107 PST [127816] DEBUG:  proc_exit(-1): 0 callbacks to make
  1. Immediate Shutdown
    • 立即关闭模式,主进程 postgres 向所有子进程发送 SIGQUIT 信号,并且立即退出,所有的子进程也会立即退出。
    • 采用这种模式退出时,并不会妥善地关闭数据库系统,下次启动时数据库会重放 WAL 日志进行恢复,因此建议只在紧急的时候使用该方法。
    • 使用 pg_ctl 命令的示例如下:
      pg_ctl stop -m immediate
      

输出日志

2024-11-27 05:58:21.525 PST [127387] DEBUG:  postmaster received shutdown request signal
2024-11-27 05:58:21.525 PST [127387] LOG:  received immediate shutdown request
2024-11-27 05:58:21.526 PST [127387] DEBUG:  sending signal 3 to process 127395
2024-11-27 05:58:21.526 PST [127387] DEBUG:  reaping dead processes
2024-11-27 05:58:21.526 PST [127387] DEBUG:  reaping dead processes
2024-11-27 05:58:21.527 PST [127387] DEBUG:  reaping dead processes
2024-11-27 05:58:21.527 PST [127387] DEBUG:  shmem_exit(0): 0 before_shmem_exit callbacks to make
2024-11-27 05:58:21.527 PST [127387] DEBUG:  shmem_exit(0): 6 on_shmem_exit callbacks to make
2024-11-27 05:58:21.531 PST [127387] DEBUG:  cleaning up orphaned dynamic shared memory with ID 2800411074
2024-11-27 05:58:21.531 PST [127387] DEBUG:  cleaning up dynamic shared memory control segment with ID 3983505204
2024-11-27 05:58:21.532 PST [127387] DEBUG:  proc_exit(0): 2 callbacks to make
2024-11-27 05:58:21.532 PST [127387] LOG:  database system is shut down
2024-11-27 05:58:21.532 PST [127387] DEBUG:  exit(0)
2024-11-27 05:58:21.532 PST [127387] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 05:58:21.532 PST [127387] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 05:58:21.532 PST [127387] DEBUG:  proc_exit(-1): 0 callbacks to make
2024-11-27 05:58:21.532 PST [127388] DEBUG:  logger shutting down
2024-11-27 05:58:21.532 PST [127388] DEBUG:  shmem_exit(0): 0 before_shmem_exit callbacks to make
2024-11-27 05:58:21.532 PST [127388] DEBUG:  shmem_exit(0): 0 on_shmem_exit callbacks to make
2024-11-27 05:58:21.532 PST [127388] DEBUG:  proc_exit(0): 0 callbacks to make
2024-11-27 05:58:21.532 PST [127388] DEBUG:  exit(0)
2024-11-27 05:58:21.533 PST [127388] DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2024-11-27 05:58:21.533 PST [127388] DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2024-11-27 05:58:21.533 PST [127388] DEBUG:  proc_exit(-1): 0 callbacks to make

这些模式分别对应不同的信号:

  • SIGTERM 对应 Smart Shutdown
  • SIGINT 对应 Fast Shutdown
  • SIGQUIT 对应 Immediate Shutdown

SIGINT 信号

[pg16@test ~]$ ps -ef |grep postgre
pg16      38940      1  0 05:32 ?        00:00:00 /home/pg16/soft/bin/postgres
pg16      38941  38940  0 05:32 ?        00:00:00 postgres: logger 
pg16      38942  38940  0 05:32 ?        00:00:00 postgres: checkpointer 
pg16      38943  38940  0 05:32 ?        00:00:00 postgres: background writer 
pg16      38945  38940  0 05:32 ?        00:00:00 postgres: walwriter 
pg16      38946  38940  0 05:32 ?        00:00:00 postgres: autovacuum launcher
pg16      38947  38940  0 05:32 ?        00:00:00 postgres: archiver 
pg16      38948  38940  0 05:32 ?        00:00:00 postgres: logical replication launcher
pg16      38954  38549  0 05:32 pts/2    00:00:00 grep --color=auto postgre
[pg16@test ~]$ pg_ctl stop -m fast[root@test ~]# gdb -p 38940
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Attaching to process 38940
Reading symbols from /home/pg16/soft/bin/postgres...(no debugging symbols found)...done.
Reading symbols from /lib64/libz.so.1...Reading symbols from /lib64/libz.so.1...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libz.so.1
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libicui18n.so.50...Reading symbols from /lib64/libicui18n.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicui18n.so.50
Reading symbols from /lib64/libicuuc.so.50...Reading symbols from /lib64/libicuuc.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicuuc.so.50
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libstdc++.so.6
Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libgcc_s.so.1
Reading symbols from /lib64/libicudata.so.50...Reading symbols from /lib64/libicudata.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicudata.so.50
Reading symbols from /home/pg16/soft/lib/postgresql/pg_stat_statements.so...(no debugging symbols found)...done.
Loaded symbols for /home/pg16/soft/lib/postgresql/pg_stat_statements.so
0x00007f7f25563f23 in __epoll_wait_nocancel () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-317.el7.x86_64 libgcc-4.8.5-44.el7.x86_64 libicu-50.2-4.el7_7.x86_64 libstdc++-4.8.5-44.el7.x86_64 zlib-1.2.7-18.el7.x86_64
(gdb) c handle_sigterm
Not stopped at any breakpoint; argument ignored.
Continuing.
cProgram received signal SIGINT, Interrupt.
0x00007f7f25563f23 in __epoll_wait_nocancel () from /lib64/libc.so.6
(gdb) c
Continuing.
c

SIGTERM 信号

[pg16@test ~]$ ps -ef |grep postgre    
pg16      38824      1  0 05:30 ?        00:00:00 /home/pg16/soft/bin/postgres
pg16      38825  38824  0 05:30 ?        00:00:00 postgres: logger 
pg16      38826  38824  0 05:30 ?        00:00:00 postgres: checkpointer 
pg16      38827  38824  0 05:30 ?        00:00:00 postgres: background writer 
pg16      38829  38824  0 05:30 ?        00:00:00 postgres: walwriter 
pg16      38830  38824  0 05:30 ?        00:00:00 postgres: autovacuum launcher
pg16      38831  38824  0 05:30 ?        00:00:00 postgres: archiver 
pg16      38832  38824  0 05:30 ?        00:00:00 postgres: logical replication launcher
pg16      38837  38549  0 05:30 pts/2    00:00:00 grep --color=auto postgre
[pg16@test ~]$ pg_ctl stop -m smart[root@test ~]# gdb -p 38824
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Attaching to process 38824
Reading symbols from /home/pg16/soft/bin/postgres...(no debugging symbols found)...done.
Reading symbols from /lib64/libz.so.1...Reading symbols from /lib64/libz.so.1...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libz.so.1
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libicui18n.so.50...Reading symbols from /lib64/libicui18n.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicui18n.so.50
Reading symbols from /lib64/libicuuc.so.50...Reading symbols from /lib64/libicuuc.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicuuc.so.50
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libstdc++.so.6
Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libgcc_s.so.1
Reading symbols from /lib64/libicudata.so.50...Reading symbols from /lib64/libicudata.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicudata.so.50
Reading symbols from /home/pg16/soft/lib/postgresql/pg_stat_statements.so...(no debugging symbols found)...done.
Loaded symbols for /home/pg16/soft/lib/postgresql/pg_stat_statements.so
0x00007fa33364bf23 in __epoll_wait_nocancel () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-317.el7.x86_64 libgcc-4.8.5-44.el7.x86_64 libicu-50.2-4.el7_7.x86_64 libstdc++-4.8.5-44.el7.x86_64 zlib-1.2.7-18.el7.x86_64
(gdb) c handle_sigterm
Not stopped at any breakpoint; argument ignored.
Continuing.
cProgram received signal SIGTERM, Terminated.
0x00007fa33364bf23 in __epoll_wait_nocancel () from /lib64/libc.so.6
(gdb) c
Continuing.
[Inferior 1 (process 38824) exited normally]

SIGQUIT信号

[pg16@test ~]$ ps -ef |grep postgre
pg16      38603      1  0 05:28 ?        00:00:00 /home/pg16/soft/bin/postgres
pg16      38604  38603  0 05:28 ?        00:00:00 postgres: logger 
pg16      38605  38603  0 05:28 ?        00:00:00 postgres: checkpointer 
pg16      38606  38603  0 05:28 ?        00:00:00 postgres: background writer 
pg16      38608  38603  0 05:28 ?        00:00:00 postgres: walwriter 
pg16      38609  38603  0 05:28 ?        00:00:00 postgres: autovacuum launcher
pg16      38610  38603  0 05:28 ?        00:00:00 postgres: archiver 
pg16      38611  38603  0 05:28 ?        00:00:00 postgres: logical replication launcher
pg16      38670  38549  0 05:28 pts/2    00:00:00 grep --color=auto postgre
[pg16@test ~]$ pg_ctl stop -m immediate[root@test ~]# gdb -p 38603
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Attaching to process 38603
Reading symbols from /home/pg16/soft/bin/postgres...(no debugging symbols found)...done.
Reading symbols from /lib64/libz.so.1...Reading symbols from /lib64/libz.so.1...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libz.so.1
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libicui18n.so.50...Reading symbols from /lib64/libicui18n.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicui18n.so.50
Reading symbols from /lib64/libicuuc.so.50...Reading symbols from /lib64/libicuuc.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicuuc.so.50
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libstdc++.so.6
Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libgcc_s.so.1
Reading symbols from /lib64/libicudata.so.50...Reading symbols from /lib64/libicudata.so.50...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/libicudata.so.50
Reading symbols from /home/pg16/soft/lib/postgresql/pg_stat_statements.so...(no debugging symbols found)...done.
Loaded symbols for /home/pg16/soft/lib/postgresql/pg_stat_statements.so
0x00007fac7f847f23 in __epoll_wait_nocancel () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-317.el7.x86_64 libgcc-4.8.5-44.el7.x86_64 libicu-50.2-4.el7_7.x86_64 libstdc++-4.8.5-44.el7.x86_64 zlib-1.2.7-18.el7.x86_64
(gdb) c handle_sigterm
Not stopped at any breakpoint; argument ignored.
Continuing.
cProgram received signal SIGQUIT, Quit.
0x00007fac7f847f23 in __epoll_wait_nocancel () from /lib64/libc.so.6
(gdb) c
Continuing.
[Inferior 1 (process 38603) exited normally]

通过这些不同的关机模式,可以根据具体需求选择合适的关机方式。


http://www.mrgr.cn/news/78416.html

相关文章:

  • C/C++基础知识复习(31)
  • Linux上安装单机版Kibana6.8.1
  • LLM应用-prompt提示:RAG query重写、相似query生成 加强检索准确率
  • Swift——类与结构体
  • 区块链:波场-TRON链
  • 简易安卓句分器实现
  • CTO 实际上是在做什么?
  • LLamafactory API部署与使用异步方式 API 调用优化大模型推理效率
  • 矩阵重新排列——sort函数
  • 使用ENSP实现默认路由
  • 蓝桥杯c++算法秒杀【6】之动态规划【上】(数字三角形、砝码称重(背包问题)、括号序列、组合数问题:::非常典型的必刷例题!!!)
  • 鸿蒙NEXT元服务:利用App Linking实现无缝跳转与二维码拉起
  • 【Leetcode Top 100】48. 旋转图像
  • 微信小程序按字母顺序渲染城市 功能实现详细讲解
  • ThingsBoard规则链节点:GCP Pub/Sub 节点详解
  • 技术文档的规划布局:构建清晰的知识蓝图
  • 【Leetcode 每日一题】632. 最小区间
  • Springboot整合分布式任务调度平台XXL-Job实现定时任务
  • 更优雅的 yolo v11 标注工具 AutoLabel Conda环境直接识别训练
  • PGSQL学习笔记 -- 从入门到放弃
  • 使用Spring Data MongoDB中的MongoTemplate实现分组查询最新的数据
  • 前端应用界面的展示与优化(记录)
  • C++学习日记---第14天(蓝桥杯备赛)
  • 什么是代理,nodenginx前端代理详解
  • vue修改el-table-column上下margin外边距调整行间距方法教程
  • 在Ubuntu2004中搭建基于ESP-IDF v5.1的ESP32-S3开发环境