gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 line
6.5KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>18.5. Shutting Down the Server</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="kernel-resources.html" title="18.4. Managing Kernel Resources" /><link rel="next" href="upgrading.html" title="18.6. Upgrading a PostgreSQL Cluster" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">18.5. Shutting Down the Server</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="kernel-resources.html" title="18.4. Managing Kernel Resources">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="runtime.html" title="Chapter 18. Server Setup and Operation">Up</a></td><th width="60%" align="center">Chapter 18. Server Setup and Operation</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="upgrading.html" title="18.6. Upgrading a PostgreSQL Cluster">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="SERVER-SHUTDOWN"><div class="titlepage"><div><div><h2 class="title" style="clear: both">18.5. Shutting Down the Server</h2></div></div></div><a id="id-1.6.5.7.2" class="indexterm"></a><p>
  3. There are several ways to shut down the database server. You control
  4. the type of shutdown by sending different signals to the master
  5. <code class="command">postgres</code> process.
  6. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="systemitem">SIGTERM</span><a id="id-1.6.5.7.3.2.1.1.2" class="indexterm"></a></span></dt><dd><p>
  7. This is the <em class="firstterm">Smart Shutdown</em> mode.
  8. After receiving <span class="systemitem">SIGTERM</span>, the server
  9. disallows new connections, but lets existing sessions end their
  10. work normally. It shuts down only after all of the sessions terminate.
  11. If the server is in online backup mode, it additionally waits
  12. until online backup mode is no longer active. While backup mode is
  13. active, new connections will still be allowed, but only to superusers
  14. (this exception allows a superuser to connect to terminate
  15. online backup mode). If the server is in recovery when a smart
  16. shutdown is requested, recovery and streaming replication will be
  17. stopped only after all regular sessions have terminated.
  18. </p></dd><dt><span class="term"><span class="systemitem">SIGINT</span><a id="id-1.6.5.7.3.2.2.1.2" class="indexterm"></a></span></dt><dd><p>
  19. This is the <em class="firstterm">Fast Shutdown</em> mode.
  20. The server disallows new connections and sends all existing
  21. server processes <span class="systemitem">SIGTERM</span>, which will cause them
  22. to abort their current transactions and exit promptly. It then
  23. waits for all server processes to exit and finally shuts down.
  24. If the server is in online backup mode, backup mode will be
  25. terminated, rendering the backup useless.
  26. </p></dd><dt><span class="term"><span class="systemitem">SIGQUIT</span><a id="id-1.6.5.7.3.2.3.1.2" class="indexterm"></a></span></dt><dd><p>
  27. This is the <em class="firstterm">Immediate Shutdown</em> mode.
  28. The server will send <span class="systemitem">SIGQUIT</span> to all child
  29. processes and wait for them to terminate. If any do not terminate
  30. within 5 seconds, they will be sent <span class="systemitem">SIGKILL</span>.
  31. The master server process exits as soon as all child processes have
  32. exited, without doing normal database shutdown processing.
  33. This will lead to recovery (by
  34. replaying the WAL log) upon next start-up. This is recommended
  35. only in emergencies.
  36. </p></dd></dl></div><p>
  37. </p><p>
  38. The <a class="xref" href="app-pg-ctl.html" title="pg_ctl"><span class="refentrytitle"><span class="application">pg_ctl</span></span></a> program provides a convenient
  39. interface for sending these signals to shut down the server.
  40. Alternatively, you can send the signal directly using <code class="command">kill</code>
  41. on non-Windows systems.
  42. The <acronym class="acronym">PID</acronym> of the <code class="command">postgres</code> process can be
  43. found using the <code class="command">ps</code> program, or from the file
  44. <code class="filename">postmaster.pid</code> in the data directory. For
  45. example, to do a fast shutdown:
  46. </p><pre class="screen">
  47. $ <strong class="userinput"><code>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</code></strong>
  48. </pre><p>
  49. </p><div class="important"><h3 class="title">Important</h3><p>
  50. It is best not to use <span class="systemitem">SIGKILL</span> to shut down the
  51. server. Doing so will prevent the server from releasing shared memory and
  52. semaphores. Furthermore, <span class="systemitem">SIGKILL</span> kills
  53. the <code class="command">postgres</code> process without letting it relay the
  54. signal to its subprocesses, so it might be necessary to kill the
  55. individual subprocesses by hand as well.
  56. </p></div><p>
  57. To terminate an individual session while allowing other sessions to
  58. continue, use <code class="function">pg_terminate_backend()</code> (see <a class="xref" href="functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE" title="Table 9.83. Server Signaling Functions">Table 9.83</a>) or send a
  59. <span class="systemitem">SIGTERM</span> signal to the child process associated with
  60. the session.
  61. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="kernel-resources.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="runtime.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="upgrading.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">18.4. Managing Kernel Resources </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 18.6. Upgrading a <span class="productname">PostgreSQL</span> Cluster</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1