gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

288 lines
28KB

  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>pg_ctl</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="app-pgcontroldata.html" title="pg_controldata" /><link rel="next" href="app-pgresetwal.html" title="pg_resetwal" /></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"><span xmlns="http://www.w3.org/1999/xhtml" class="application">pg_ctl</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgcontroldata.html" title="pg_controldata">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQL Server Applications">Up</a></td><th width="60%" align="center">PostgreSQL Server Applications</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="app-pgresetwal.html" title="pg_resetwal">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="APP-PG-CTL"><div class="titlepage"></div><a id="id-1.9.5.7.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_ctl</span></span></h2><p>pg_ctl — initialize, start, stop, or control a <span class="productname">PostgreSQL</span> server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.5.7.4.1"><code class="command">pg_ctl</code> <code class="option">init[db]</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>initdb-options</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.2"><code class="command">pg_ctl</code> <code class="option">start</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-l</code> <em class="replaceable"><code>filename</code></em>] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>options</code></em>] [<code class="option">-p</code> <em class="replaceable"><code>path</code></em>] [<code class="option">-c</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.3"><code class="command">pg_ctl</code> <code class="option">stop</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-m</code>
  3. <code class="option">s[mart]</code> | <code class="option">f[ast]</code> | <code class="option">i[mmediate]</code>
  4. ] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.4"><code class="command">pg_ctl</code> <code class="option">restart</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-m</code>
  5. <code class="option">s[mart]</code> | <code class="option">f[ast]</code> | <code class="option">i[mmediate]</code>
  6. ] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>options</code></em>] [<code class="option">-c</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.5"><code class="command">pg_ctl</code> <code class="option">reload</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.6"><code class="command">pg_ctl</code> <code class="option">status</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.7"><code class="command">pg_ctl</code> <code class="option">promote</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.8"><code class="command">pg_ctl</code> <code class="option">logrotate</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-s</code>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.9"><code class="command">pg_ctl</code> <code class="option">kill</code> <em class="replaceable"><code>signal_name</code></em> <em class="replaceable"><code>process_id</code></em> </p></div><p>On Microsoft Windows, also:</p><div class="cmdsynopsis"><p id="id-1.9.5.7.4.11"><code class="command">pg_ctl</code> <code class="option">register</code> [<code class="option">-D</code> <em class="replaceable"><code>datadir</code></em>] [<code class="option">-N</code> <em class="replaceable"><code>servicename</code></em>] [<code class="option">-U</code> <em class="replaceable"><code>username</code></em>] [<code class="option">-P</code> <em class="replaceable"><code>password</code></em>] [<code class="option">-S</code>
  7. <code class="option">a[uto]</code> | <code class="option">d[emand]</code>
  8. ] [<code class="option">-e</code> <em class="replaceable"><code>source</code></em>] [<code class="option">-W</code>] [<code class="option">-t</code> <em class="replaceable"><code>seconds</code></em>] [<code class="option">-s</code>] [<code class="option">-o</code> <em class="replaceable"><code>options</code></em>]</p></div><div class="cmdsynopsis"><p id="id-1.9.5.7.4.12"><code class="command">pg_ctl</code> <code class="option">unregister</code> [<code class="option">-N</code> <em class="replaceable"><code>servicename</code></em>]</p></div></div><div class="refsect1" id="APP-PG-CTL-DESCRIPTION"><h2>Description</h2><p>
  9. <span class="application">pg_ctl</span> is a utility for initializing a
  10. <span class="productname">PostgreSQL</span> database cluster, starting,
  11. stopping, or restarting the <span class="productname">PostgreSQL</span>
  12. database server (<a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a>), or displaying the
  13. status of a running server. Although the server can be started
  14. manually, <span class="application">pg_ctl</span> encapsulates tasks such
  15. as redirecting log output and properly detaching from the terminal
  16. and process group. It also provides convenient options for
  17. controlled shutdown.
  18. </p><p>
  19. The <code class="option">init</code> or <code class="option">initdb</code> mode creates a new
  20. <span class="productname">PostgreSQL</span> database cluster, that is,
  21. a collection of databases that will be managed by a single
  22. server instance. This mode invokes the <code class="command">initdb</code>
  23. command. See <a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle">initdb</span></a> for details.
  24. </p><p>
  25. <code class="option">start</code> mode launches a new server. The
  26. server is started in the background, and its standard input is attached
  27. to <code class="filename">/dev/null</code> (or <code class="literal">nul</code> on Windows).
  28. On Unix-like systems, by default, the server's standard output and
  29. standard error are sent to <span class="application">pg_ctl</span>'s
  30. standard output (not standard error). The standard output of
  31. <span class="application">pg_ctl</span> should then be redirected to a
  32. file or piped to another process such as a log rotating program
  33. like <span class="application">rotatelogs</span>; otherwise <code class="command">postgres</code>
  34. will write its output to the controlling terminal (from the
  35. background) and will not leave the shell's process group. On
  36. Windows, by default the server's standard output and standard error
  37. are sent to the terminal. These default behaviors can be changed
  38. by using <code class="option">-l</code> to append the server's output to a log file.
  39. Use of either <code class="option">-l</code> or output redirection is recommended.
  40. </p><p>
  41. <code class="option">stop</code> mode shuts down the server that is running in
  42. the specified data directory. Three different
  43. shutdown methods can be selected with the <code class="option">-m</code>
  44. option. <span class="quote">“<span class="quote">Smart</span>”</span> mode waits for all active
  45. clients to disconnect and any online backup to finish.
  46. If the server is in hot standby, recovery and streaming replication
  47. will be terminated once all clients have disconnected.
  48. <span class="quote">“<span class="quote">Fast</span>”</span> mode (the default) does not wait for clients to disconnect and
  49. will terminate an online backup in progress. All active transactions are
  50. rolled back and clients are forcibly disconnected, then the
  51. server is shut down. <span class="quote">“<span class="quote">Immediate</span>”</span> mode will abort
  52. all server processes immediately, without a clean shutdown. This choice
  53. will lead to a crash-recovery cycle during the next server start.
  54. </p><p>
  55. <code class="option">restart</code> mode effectively executes a stop followed
  56. by a start. This allows changing the <code class="command">postgres</code>
  57. command-line options, or changing configuration-file options that
  58. cannot be changed without restarting the server.
  59. If relative paths were used on the command line during server
  60. start, <code class="option">restart</code> might fail unless
  61. <span class="application">pg_ctl</span> is executed in the same current
  62. directory as it was during server start.
  63. </p><p>
  64. <code class="option">reload</code> mode simply sends the
  65. <code class="command">postgres</code> server process a <span class="systemitem">SIGHUP</span>
  66. signal, causing it to reread its configuration files
  67. (<code class="filename">postgresql.conf</code>,
  68. <code class="filename">pg_hba.conf</code>, etc.). This allows changing
  69. configuration-file options that do not require a full server restart
  70. to take effect.
  71. </p><p>
  72. <code class="option">status</code> mode checks whether a server is running in
  73. the specified data directory. If it is, the server's <acronym class="acronym">PID</acronym>
  74. and the command line options that were used to invoke it are displayed.
  75. If the server is not running, <span class="application">pg_ctl</span> returns
  76. an exit status of 3. If an accessible data directory is not
  77. specified, <span class="application">pg_ctl</span> returns an exit status of 4.
  78. </p><p>
  79. <code class="option">promote</code> mode commands the standby server that is
  80. running in the specified data directory to end standby mode
  81. and begin read-write operations.
  82. </p><p>
  83. <code class="option">logrotate</code> mode rotates the server log file.
  84. For details on how to use this mode with external log rotation tools, see
  85. <a class="xref" href="logfile-maintenance.html" title="24.3. Log File Maintenance">Section 24.3</a>.
  86. </p><p>
  87. <code class="option">kill</code> mode sends a signal to a specified process.
  88. This is primarily valuable on <span class="productname">Microsoft Windows</span>
  89. which does not have a built-in <span class="application">kill</span> command. Use
  90. <code class="literal">--help</code> to see a list of supported signal names.
  91. </p><p>
  92. <code class="option">register</code> mode registers the <span class="productname">PostgreSQL</span>
  93. server as a system service on <span class="productname">Microsoft Windows</span>.
  94. The <code class="option">-S</code> option allows selection of service start type,
  95. either <span class="quote">“<span class="quote">auto</span>”</span> (start service automatically on system startup)
  96. or <span class="quote">“<span class="quote">demand</span>”</span> (start service on demand).
  97. </p><p>
  98. <code class="option">unregister</code> mode unregisters a system service
  99. on <span class="productname">Microsoft Windows</span>. This undoes the effects of the
  100. <code class="option">register</code> command.
  101. </p></div><div class="refsect1" id="APP-PG-CTL-OPTIONS"><h2>Options</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--core-files</code></span></dt><dd><p>
  102. Attempt to allow server crashes to produce core files, on platforms
  103. where this is possible, by lifting any soft resource limit placed on
  104. core files.
  105. This is useful in debugging or diagnosing problems by allowing a
  106. stack trace to be obtained from a failed server process.
  107. </p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>datadir</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>datadir</code></em></code></span></dt><dd><p>
  108. Specifies the file system location of the database configuration files. If
  109. this option is omitted, the environment variable
  110. <code class="envar">PGDATA</code> is used.
  111. </p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--log=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
  112. Append the server log output to
  113. <em class="replaceable"><code>filename</code></em>. If the file does not
  114. exist, it is created. The <span class="systemitem">umask</span> is set to 077,
  115. so access to the log file is disallowed to other users by default.
  116. </p></dd><dt><span class="term"><code class="option">-m <em class="replaceable"><code>mode</code></em></code><br /></span><span class="term"><code class="option">--mode=<em class="replaceable"><code>mode</code></em></code></span></dt><dd><p>
  117. Specifies the shutdown mode. <em class="replaceable"><code>mode</code></em>
  118. can be <code class="literal">smart</code>, <code class="literal">fast</code>, or
  119. <code class="literal">immediate</code>, or the first letter of one of
  120. these three. If this option is omitted, <code class="literal">fast</code> is
  121. the default.
  122. </p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>options</code></em></code><br /></span><span class="term"><code class="option">--options=<em class="replaceable"><code>options</code></em></code></span></dt><dd><p>
  123. Specifies options to be passed directly to the
  124. <code class="command">postgres</code> command.
  125. <code class="option">-o</code> can be specified multiple times, with all the given
  126. options being passed through.
  127. </p><p>
  128. The <em class="replaceable"><code>options</code></em> should usually be surrounded by single or
  129. double quotes to ensure that they are passed through as a group.
  130. </p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>initdb-options</code></em></code><br /></span><span class="term"><code class="option">--options=<em class="replaceable"><code>initdb-options</code></em></code></span></dt><dd><p>
  131. Specifies options to be passed directly to the
  132. <code class="command">initdb</code> command.
  133. <code class="option">-o</code> can be specified multiple times, with all the given
  134. options being passed through.
  135. </p><p>
  136. The <em class="replaceable"><code>initdb-options</code></em> should usually be surrounded by single or
  137. double quotes to ensure that they are passed through as a group.
  138. </p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>path</code></em></code></span></dt><dd><p>
  139. Specifies the location of the <code class="filename">postgres</code>
  140. executable. By default the <code class="filename">postgres</code> executable is taken from the same
  141. directory as <code class="command">pg_ctl</code>, or failing that, the hard-wired
  142. installation directory. It is not necessary to use this
  143. option unless you are doing something unusual and get errors
  144. that the <code class="filename">postgres</code> executable was not found.
  145. </p><p>
  146. In <code class="literal">init</code> mode, this option analogously
  147. specifies the location of the <code class="filename">initdb</code>
  148. executable.
  149. </p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--silent</code></span></dt><dd><p>
  150. Print only errors, no informational messages.
  151. </p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>seconds</code></em></code><br /></span><span class="term"><code class="option">--timeout=<em class="replaceable"><code>seconds</code></em></code></span></dt><dd><p>
  152. Specifies the maximum number of seconds to wait when waiting for an
  153. operation to complete (see option <code class="option">-w</code>). Defaults to
  154. the value of the <code class="envar">PGCTLTIMEOUT</code> environment variable or, if
  155. not set, to 60 seconds.
  156. </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
  157. Print the <span class="application">pg_ctl</span> version and exit.
  158. </p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--wait</code></span></dt><dd><p>
  159. Wait for the operation to complete. This is supported for the
  160. modes <code class="literal">start</code>, <code class="literal">stop</code>,
  161. <code class="literal">restart</code>, <code class="literal">promote</code>,
  162. and <code class="literal">register</code>, and is the default for those modes.
  163. </p><p>
  164. When waiting, <code class="command">pg_ctl</code> repeatedly checks the
  165. server's <acronym class="acronym">PID</acronym> file, sleeping for a short amount
  166. of time between checks. Startup is considered complete when
  167. the <acronym class="acronym">PID</acronym> file indicates that the server is ready to
  168. accept connections. Shutdown is considered complete when the server
  169. removes the <acronym class="acronym">PID</acronym> file.
  170. <code class="command">pg_ctl</code> returns an exit code based on the
  171. success of the startup or shutdown.
  172. </p><p>
  173. If the operation does not complete within the timeout (see
  174. option <code class="option">-t</code>), then <code class="command">pg_ctl</code> exits with
  175. a nonzero exit status. But note that the operation might continue in
  176. the background and eventually succeed.
  177. </p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--no-wait</code></span></dt><dd><p>
  178. Do not wait for the operation to complete. This is the opposite of
  179. the option <code class="option">-w</code>.
  180. </p><p>
  181. If waiting is disabled, the requested action is triggered, but there
  182. is no feedback about its success. In that case, the server log file
  183. or an external monitoring system would have to be used to check the
  184. progress and success of the operation.
  185. </p><p>
  186. In prior releases of PostgreSQL, this was the default except for
  187. the <code class="literal">stop</code> mode.
  188. </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
  189. Show help about <span class="application">pg_ctl</span> command line
  190. arguments, and exit.
  191. </p></dd></dl></div><p>
  192. If an option is specified that is valid, but not relevant to the selected
  193. operating mode, <span class="application">pg_ctl</span> ignores it.
  194. </p><div class="refsect2" id="APP-PG-CTL-WINDOWS-OPTIONS"><h3>Options for Windows</h3><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-e <em class="replaceable"><code>source</code></em></code></span></dt><dd><p>
  195. Name of the event source for <span class="application">pg_ctl</span> to use
  196. for logging to the event log when running as a Windows service. The
  197. default is <code class="literal">PostgreSQL</code>. Note that this only controls
  198. messages sent from <span class="application">pg_ctl</span> itself; once
  199. started, the server will use the event source specified
  200. by its <a class="xref" href="runtime-config-logging.html#GUC-EVENT-SOURCE">event_source</a> parameter. Should the server
  201. fail very early in startup, before that parameter has been set,
  202. it might also log using the default event
  203. source name <code class="literal">PostgreSQL</code>.
  204. </p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>servicename</code></em></code></span></dt><dd><p>
  205. Name of the system service to register. This name will be used
  206. as both the service name and the display name.
  207. The default is <code class="literal">PostgreSQL</code>.
  208. </p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>password</code></em></code></span></dt><dd><p>
  209. Password for the user to run the service as.
  210. </p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>start-type</code></em></code></span></dt><dd><p>
  211. Start type of the system service. <em class="replaceable"><code>start-type</code></em> can
  212. be <code class="literal">auto</code>, or <code class="literal">demand</code>, or
  213. the first letter of one of these two. If this option is omitted,
  214. <code class="literal">auto</code> is the default.
  215. </p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
  216. User name for the user to run the service as. For domain users, use the
  217. format <code class="literal">DOMAIN\username</code>.
  218. </p></dd></dl></div></div></div><div class="refsect1" id="id-1.9.5.7.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGCTLTIMEOUT</code></span></dt><dd><p>
  219. Default limit on the number of seconds to wait when waiting for startup
  220. or shutdown to complete. If not set, the default is 60 seconds.
  221. </p></dd><dt><span class="term"><code class="envar">PGDATA</code></span></dt><dd><p>
  222. Default data directory location.
  223. </p></dd></dl></div><p>
  224. Most <code class="command">pg_ctl</code> modes require knowing the data directory
  225. location; therefore, the <code class="option">-D</code> option is required
  226. unless <code class="envar">PGDATA</code> is set.
  227. </p><p>
  228. <code class="command">pg_ctl</code>, like most other <span class="productname">PostgreSQL</span>
  229. utilities,
  230. also uses the environment variables supported by <span class="application">libpq</span>
  231. (see <a class="xref" href="libpq-envars.html" title="33.14. Environment Variables">Section 33.14</a>).
  232. </p><p>
  233. For additional variables that affect the server,
  234. see <a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a>.
  235. </p></div><div class="refsect1" id="id-1.9.5.7.8"><h2>Files</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="filename">postmaster.pid</code></span></dt><dd><p>
  236. <span class="application">pg_ctl</span> examines this file in the data
  237. directory to determine whether the server is currently running.
  238. </p></dd><dt><span class="term"><code class="filename">postmaster.opts</code></span></dt><dd><p>If this file exists in the data directory,
  239. <span class="application">pg_ctl</span> (in <code class="option">restart</code> mode)
  240. will pass the contents of the file as options to
  241. <span class="application">postgres</span>, unless overridden
  242. by the <code class="option">-o</code> option. The contents of this file
  243. are also displayed in <code class="option">status</code> mode.
  244. </p></dd></dl></div></div><div class="refsect1" id="R1-APP-PGCTL-2"><h2>Examples</h2><div class="refsect2" id="R2-APP-PGCTL-3"><h3>Starting the Server</h3><p>
  245. To start the server, waiting until the server is
  246. accepting connections:
  247. </p><pre class="screen">
  248. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl start</code></strong>
  249. </pre><p>
  250. </p><p>
  251. To start the server using port 5433, and
  252. running without <code class="function">fsync</code>, use:
  253. </p><pre class="screen">
  254. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl -o "-F -p 5433" start</code></strong>
  255. </pre></div><div class="refsect2" id="R2-APP-PGCTL-4"><h3>Stopping the Server</h3><p>
  256. To stop the server, use:
  257. </p><pre class="screen">
  258. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl stop</code></strong>
  259. </pre><p>
  260. The <code class="option">-m</code> option allows control over
  261. <span class="emphasis"><em>how</em></span> the server shuts down:
  262. </p><pre class="screen">
  263. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl stop -m smart</code></strong>
  264. </pre></div><div class="refsect2" id="R2-APP-PGCTL-5"><h3>Restarting the Server</h3><p>
  265. Restarting the server is almost equivalent to stopping the
  266. server and starting it again, except that by default,
  267. <code class="command">pg_ctl</code> saves and reuses the command line options that
  268. were passed to the previously-running instance. To restart
  269. the server using the same options as before, use:
  270. </p><pre class="screen">
  271. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl restart</code></strong>
  272. </pre><p>
  273. </p><p>
  274. But if <code class="option">-o</code> is specified, that replaces any previous options.
  275. To restart using port 5433, disabling <code class="function">fsync</code> upon restart:
  276. </p><pre class="screen">
  277. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl -o "-F -p 5433" restart</code></strong>
  278. </pre></div><div class="refsect2" id="R2-APP-PGCTL-6"><h3>Showing the Server Status</h3><p>
  279. Here is sample status output from
  280. <span class="application">pg_ctl</span>:
  281. </p><pre class="screen">
  282. <code class="prompt">$</code> <strong class="userinput"><code>pg_ctl status</code></strong>
  283. <code class="computeroutput">
  284. pg_ctl: server is running (PID: 13718)
  285. /usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data" "-p" "5433" "-B" "128"
  286. </code></pre><p>
  287. The second line is the command that would be invoked in restart mode.
  288. </p></div></div><div class="refsect1" id="id-1.9.5.7.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-initdb.html" title="initdb"><span class="refentrytitle">initdb</span></a>, <a class="xref" href="app-postgres.html" title="postgres"><span class="refentrytitle"><span class="application">postgres</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgcontroldata.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgresetwal.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_controldata</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_resetwal</span></td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1