PostgreSql start and stop

1. Start

  • Run the postgres process directly to start.
  • Start with the pg_ctl command. (The pg_ctl command is actually an encapsulated postgres process)

Example :

pg_ctl -D /data/pg13/data start
postgres -D /data/pg13/data &

Two, stop

  • Use the pg_ctl command to stop, and this method is preferred.
  • The kill shutdown method will prevent the server from releasing shared memory and semaphores. When using kill to kill a postgres process, postgres will not have the opportunity to propagate the signal to its child processes. You may have to manually kill individual child processes.

Example :

--等待所有客户端断开连接以及任何在线备份结束,相当于 Oracle:shutwodn normal
pg_ctl stop -m smart
kill `head -1 /data/pg13/data/postmaster.pid`
kill -term `head -1 /data/pg13/data/postmaster.pid`

--默认方式,不会等待客户端断开连接并且将终止进行中的在线备份。所有活动事务都被回滚并且客户端被强制断开连接,相当于 Oracle:shutwodn immediate
pg_ctl stop -m fast
kill -int `head -1 /data/pg13/data/postmaster.pid`

--将立刻中止所有连接,而不是做一次干净的关闭。这将导致下一次重启时进行一次崩溃恢复,相当于 Oracle:shutwodn abort
pg_ctl stop -m immediate
kill -quit `head -1 /data/pg13/data/postmaster.pid`

Guess you like

Origin blog.csdn.net/songyundong1993/article/details/132079981