zoukankan      html  css  js  c++  java
  • postgresql三种shutdown

      PostgreSQL shutdown有三种模式:

    • smart:PostgreSQL 9.5之前,默认是该值,它需要等待会话全部退出后才停止。这几乎是不可能的。oracle的normal模式,也就是默认。
    • fast:停止所有会话,执行检查点。相当于oracle的shutdown immeidate;
    • immediate:停止所有会话,不执行检查点,相当于oracle的shutdown abort;

      因为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) SIGUSR1
    11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
    16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
    21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
    26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
    31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
    38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
    43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
    48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
    53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
    58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
    63) SIGRTMAX-1  64) SIGRTMAX

    执行kill -SIGxxx即可,不需要包含SIG三个字母。每个信号量的含义如下:

    Action

    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

    Standard Signals

    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.postgresql.org/docs/14/server-shutdown.html 

    花若盛开,蝶自飞来,你若精彩,幸福开怀!2020年12月11日-18日
  • 相关阅读:
    【Docker 命令】- ps命令
    【Docker 命令】- exec命令
    【Docker 命令】- create命令
    【Docker 命令】- pause/unpause 命令
    【Docker 命令】- rm命令
    【Docker 命令】- kill命令
    【Docker 命令】- start/stop/restart命令
    【Docker 命令】- run命令
    【Docker】- 基本命令
    深度学习原理与框架- batch_normalize(归一化操作)
  • 原文地址:https://www.cnblogs.com/zhjh256/p/14961181.html
Copyright © 2011-2022 走看看