ITPub博客

首页 > 数据库 > > PostgreSQL-三种关闭方式(二)

PostgreSQL-三种关闭方式(二)

作者:哎呀我的天呐 时间:2019-08-01 11:29:28 0 删除 编辑
[postgres@pg01~]$ pg_ctl --help
pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server.
 
Usage:
  pg_ctl init[db] [-D DATADIR] [-s] [-o OPTIONS]
  pg_ctl start    [-D DATADIR] [-l FILENAME] [-W] [-t SECS] [-s]
                  [-o OPTIONS] [-p PATH] [-c]
  pg_ctl stop     [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s]
  pg_ctl restart  [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s]
                  [-o OPTIONS] [-c]
  pg_ctl reload   [-D DATADIR] [-s]
  pg_ctl status   [-D DATADIR]
  pg_ctl promote  [-D DATADIR] [-W] [-t SECS] [-s]
  pg_ctl kill     SIGNALNAME PID
 
Common options:
  -D, --pgdata=DATADIR   location of the database storage area
  -s, --silent           only print errors, no informational messages
  -t, --timeout=SECS     seconds to wait when using -w option
  -V, --version          output version information, then exit
  -w, --wait             wait until operation completes (default)
  -W, --no-wait          do not wait until operation completes
  -?, --help             show this help, then exit
If the -D option is omitted, the environment variable PGDATA is used.
 
Options for start or restart:
  -c, --core-files       allow postgres to produce core files
  -l, --log=FILENAME     write (or append) server log to FILENAME
  -o, --options=OPTIONS  command line options to pass to postgres
                         (PostgreSQL server executable) or initdb
  -p PATH-TO-POSTGRES    normally not necessary
 
Options for stop or restart:
  -m, --mode=MODE        MODE can be "smart", "fast", or "immediate"
 
Shutdown modes are:
  smart       quit after all clients have disconnected
  fast        quit directly, with proper shutdown (default)
  immediate   quit without complete shutdown; will lead to recovery on restart
 
Allowed signal names for kill:
  ABRT HUP INT KILL QUIT TERM USR1 USR2
 
Report bugs to .


SIGTERM : Smart Shutdown 关机模式

这是智能关机模式。收到SIGTERM后,服务器不允许新连接,但让现有会话正常结束工作。它仅在所有会话终止后关闭。如果服务器处于联机备份模式,则它还会等待,直到联机备份模式不再处于活动状态。

备份模式处于活动状态时,仍然允许新连接,但仅限于超级用户(此例外允许超级用户连接以终止联机备份模式)。如果在请求智能关闭时服务器处于恢复状态,则只有在所有常规会话终止后,才会停止恢复和流复制。

pg_ctl stop -m smart

 [postgres@slave01~]$ pg_ctl stop -D /usr/local/pgsql/data -m smart

waiting for server to shut down.... done

server stopped

SIGTERM "Smart" 模式等待所有客户端断开连接以及任何在线备份结束。如果该服务器是热备,一旦所有的客户端已经断开连接,恢复和流复制将被终止。

SIGINT : Fast Shutdown 关机模式

     默认关闭模式,快速关机模式。服务器不允许新连接并发送所有现有服务器进程SIGTERM,这将导致它们中止当前事务并立即退出。然后它等待所有服务器进程退出并最终关闭。如果服务器处于联机备份模式,则备份模式将终止,从而使备份无效。

pg_ctl stop -m fast

SIGINT "Fast" 模式不会等待客户端断开连接并且将终止进行中的在线备份。所有活动事务都被回滚并且客户端被强制断开连接,然后服务器被关闭。

SIGQUIT : Immediate Shutdown 模式

这是立即关机模式。服务器将SIGQUIT发送到所有子进程并等待它们终止。如果有任何不在5秒内终止,他们将被发送SIGKILL。主服务器进程在所有子进程退出后立即退出,而不执行正常的数据库关闭处理。这将导致在下次启动时恢复(通过重放WAL日志)。建议仅在紧急情况下使用。

pg_ctl stop -m immediate

SIGQUIT "Immediate" 模式将立刻中止所有服务器进程,而不是做一次干净的关闭。这将导致下一次重启时进行一次崩溃恢复。

 

下面是 pg_ctl 的语法

             



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29990276/viewspace-3155185/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
https://cloud.tencent.com/developer/inventory/14362

注册时间:2014-10-30

  • 博文量
    403
  • 访问量
    2528744