PostgreSQL shutdown有三种模式:
因为pg的检查点是全量的,如果希望尽可能影响时间短,可以采用下列方式停止:
psql -c CHECKPOINT && pg_ctl stop -m fast
https://www.enterprisedb.com/blog/postgresql-shutdown
除了通过pg_ctl停止外,也可以通过kill -SIGN停止pg进程。信号清单以及含义参见https://www.valinv.com/dev/linux-linux-signals-list。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | kill-l 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR111) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+338) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+843) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+1348) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-1253) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-758) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-263) SIGRTMAX-1  64) SIGRTMAX | 
执行kill -SIGxxx即可,不需要包含SIG三个字母。每个信号量的含义如下:
| Action | Description | 
| Term | Terminate the process | 
| Core | Terminate the process and dump core | 
| Ign | Ignore the signal (cause a process toterminate and produce a core dump file, a disk file (named core of the current working directory of the process. On Linux, the name is configured through /proc/sys/kernel/core_pattern) containing animage of the process‘s memory at the time of termination.) | 
| Stop | Stop the process | 
| Cont | Continue the process if it is currently stopped | 
| Name | Value | Default Action | Description | 
| SIGHUP | 1 | Term | Hangup detected on controlling terminalor death of controlling process. | 
| SIGINT | 2 | Term | Interrupt from keyboard (often DELETE or Control-C) | 
| SIGQUIT | 3 | Term + Core | Quit from keyboard (often Control-backslash) | 
| SIGILL | 4 | Term + Core | Illegal Instruction | 
| SIGTRAP | 5 | Term + Core | Trace/breakpoint trap | 
| SIGABRT | 6 | Term + Core | Abort signal from abort (calling the abort function) | 
| SIGBUS | 10,7,10 | Term + Core | Bus error (bad memory access) | 
| SIGFPE | 8 | Term + Core | Arithmetic exception (such as divide by 0, floating-point overflow, and so on) | 
| SIGKILL | 9 | Term | Kill signal (It provides the system administrator with a sure way to kill any process) | 
| SIGUSR1 | 30,10,16 | Term | User-defined signal 1, for use in application programs | 
| SIGSEGV | 11 | Term + Core | Invalid memory reference (stands for "segmentation violation") | 
| SIGUSR2 | 31,12,17 | Term | User-defined signal 2, for use in application programs | 
| SIGPIPE | 13 | Term | Broken pipe: write to pipe with noreaders (If we write to a pipeline but the reader has terminated, SIGPIPE is generated) | 
| SIGALRM | 14 | Term | Timer signal from alarm (calling the alarm function) | 
| SIGTERM | 15 | Term | Termination signal (Using SIGTERM gives programs a chance to terminate gracefully by cleaning up before exiting (in contrast to SIGKILL, which can‘t be caught or ignored)) | 
| SIGSTKFLT | -,16,- | Term | Stack fault on coprocessor (unused) | 
| SIGCHLD | 20,17,18 | Ign | Child stopped or terminated (Whenever a process terminates or stops, the SIGCHLD signal is sent to the parent. By default, this signal is ignored, so the parent must catch this signal if it wants to be notified whenever a child‘s status changes. The normal action in the signal-catching function is to call one of the wait functions to fetch the child‘s process ID and termination status) | 
| SIGCONT | 19,18,25 | Cont / Ign | Continue if a process stopped | 
| SIGSTOP | 17,19,23 | Stop | Stop process | 
| SIGTSTP | 18,20,24 | Stop | Stop typed at terminal (often Control-Z) | 
| SIGTTIN | 21,21,26 | Stop | Terminal input for background process (generated when a process in a background process group tries to read from its controlling terminal) | 
| SIGTTOU | 22,22,27 | Stop | Terminal output for background process (generated when a process in a background process group tries to write to its controlling terminal) | 
| SIGURG | 16,23,21 | Ign | Urgent condition on socket (generated when out-of-band data is received on a network connection) | 
| SIGXCPU | 24,24,30 | Term / (Term + Core) | CPU time limit exceeded (generated when a process exceeds its soft CPU time limit) | 
| SIGXFSZ | 25,25,31 | Term / (Term + Core) | File size limit exceeded (generated when a process exceeds its soft file size limit) | 
| SIGVTALRM | 26,26,28 | Term | Virtual alarm clock (generated when a virtual interval timer set by the setitimer(2) function expires) | 
| SIGPROF | 27,27,29 | Term | Profiling timer expired (generated when a profiling interval timer set by the setitimer(2) function expires) | 
| SIGWINCH | 28,28,20 | Ign | Window resize signal (The kernel maintains the size of the window associated with each terminal and pseudo terminal. A process can get and set the window size with the ioctl function. If a process changes the window size from its previous value using the ioctl set-window-size command, the kernel generates the SIGWINCH signal for the foreground process group) | 
| SIGIO | 23,29,22 | Term / Ign | I/O now possible (Indicates an asynchronous I/O event) | 
| SIGPWR | 29,30,19 | Term / Ign | Power fail/restart (Its main use is on a system that has an uninterruptible power supply (UPS)) | 
| SIGSYS | 12,31,12 | Term + Core | Bad argument to routine (Invalid system call. This might happen if you build a program that uses a new system call and you then try to run the same binary on an older version of the operating system where the system call doesn‘t exist) | 
Note: The signals SIGKILL and SIGSTOP cannot be caught, blocked, orignored.
原文:https://www.cnblogs.com/zhjh256/p/14961181.html