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.

471 lines
32KB

  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>52.4. Streaming Replication Protocol</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="sasl-authentication.html" title="52.3. SASL Authentication" /><link rel="next" href="protocol-logical-replication.html" title="52.5. Logical Streaming Replication Protocol" /></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">52.4. Streaming Replication Protocol</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sasl-authentication.html" title="52.3. SASL Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="protocol.html" title="Chapter 52. Frontend/Backend Protocol">Up</a></td><th width="60%" align="center">Chapter 52. Frontend/Backend Protocol</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="protocol-logical-replication.html" title="52.5. Logical Streaming Replication Protocol">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PROTOCOL-REPLICATION"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.4. Streaming Replication Protocol</h2></div></div></div><p>
  3. To initiate streaming replication, the frontend sends the
  4. <code class="literal">replication</code> parameter in the startup message. A Boolean
  5. value of <code class="literal">true</code> (or <code class="literal">on</code>,
  6. <code class="literal">yes</code>, <code class="literal">1</code>) tells the backend to go into
  7. physical replication walsender mode, wherein a small set of replication
  8. commands, shown below, can be issued instead of SQL statements.
  9. </p><p>
  10. Passing <code class="literal">database</code> as the value for the
  11. <code class="literal">replication</code> parameter instructs the backend to go into
  12. logical replication walsender mode, connecting to the database specified in
  13. the <code class="literal">dbname</code> parameter. In logical replication walsender
  14. mode, the replication commands shown below as well as normal SQL commands can
  15. be issued.
  16. </p><p>
  17. In either physical replication or logical replication walsender mode, only the
  18. simple query protocol can be used.
  19. </p><p>
  20. For the purpose of testing replication commands, you can make a replication
  21. connection via <span class="application">psql</span> or any other <code class="literal">libpq</code>-using
  22. tool with a connection string including the <code class="literal">replication</code> option,
  23. e.g.:
  24. </p><pre class="programlisting">
  25. psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;"
  26. </pre><p>
  27. However, it is often more useful to use
  28. <a class="xref" href="app-pgreceivewal.html" title="pg_receivewal"><span class="refentrytitle">pg_receivewal</span></a> (for physical replication) or
  29. <a class="xref" href="app-pgrecvlogical.html" title="pg_recvlogical"><span class="refentrytitle"><span class="application">pg_recvlogical</span></span></a> (for logical replication).
  30. </p><p>
  31. Replication commands are logged in the server log when
  32. <a class="xref" href="runtime-config-logging.html#GUC-LOG-REPLICATION-COMMANDS">log_replication_commands</a> is enabled.
  33. </p><p>
  34. The commands accepted in replication mode are:
  35. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">IDENTIFY_SYSTEM</code>
  36. <a id="id-1.10.5.9.7.1.1.1.2" class="indexterm"></a>
  37. </span></dt><dd><p>
  38. Requests the server to identify itself. Server replies with a result
  39. set of a single row, containing four fields:
  40. </p><p>
  41. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  42. <code class="literal">systemid</code> (<code class="type">text</code>)
  43. </span></dt><dd><p>
  44. The unique system identifier identifying the cluster. This
  45. can be used to check that the base backup used to initialize the
  46. standby came from the same cluster.
  47. </p></dd><dt><span class="term">
  48. <code class="literal">timeline</code> (<code class="type">int4</code>)
  49. </span></dt><dd><p>
  50. Current timeline ID. Also useful to check that the standby is
  51. consistent with the master.
  52. </p></dd><dt><span class="term">
  53. <code class="literal">xlogpos</code> (<code class="type">text</code>)
  54. </span></dt><dd><p>
  55. Current WAL flush location. Useful to get a known location in the
  56. write-ahead log where streaming can start.
  57. </p></dd><dt><span class="term">
  58. <code class="literal">dbname</code> (<code class="type">text</code>)
  59. </span></dt><dd><p>
  60. Database connected to or null.
  61. </p></dd></dl></div><p>
  62. </p></dd><dt><span class="term"><code class="literal">SHOW</code> <em class="replaceable"><code>name</code></em>
  63. <a id="id-1.10.5.9.7.1.2.1.3" class="indexterm"></a>
  64. </span></dt><dd><p>
  65. Requests the server to send the current setting of a run-time parameter.
  66. This is similar to the SQL command <a class="xref" href="sql-show.html" title="SHOW"><span class="refentrytitle">SHOW</span></a>.
  67. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
  68. The name of a run-time parameter. Available parameters are documented
  69. in <a class="xref" href="runtime-config.html" title="Chapter 19. Server Configuration">Chapter 19</a>.
  70. </p></dd></dl></div></dd><dt><span class="term"><code class="literal">TIMELINE_HISTORY</code> <em class="replaceable"><code>tli</code></em>
  71. <a id="id-1.10.5.9.7.1.3.1.3" class="indexterm"></a>
  72. </span></dt><dd><p>
  73. Requests the server to send over the timeline history file for timeline
  74. <em class="replaceable"><code>tli</code></em>. Server replies with a
  75. result set of a single row, containing two fields:
  76. </p><p>
  77. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  78. <code class="literal">filename</code> (<code class="type">text</code>)
  79. </span></dt><dd><p>
  80. File name of the timeline history file, e.g., <code class="filename">00000002.history</code>.
  81. </p></dd><dt><span class="term">
  82. <code class="literal">content</code> (<code class="type">bytea</code>)
  83. </span></dt><dd><p>
  84. Contents of the timeline history file.
  85. </p></dd></dl></div><p>
  86. </p></dd><dt id="PROTOCOL-REPLICATION-CREATE-SLOT"><span class="term"><code class="literal">CREATE_REPLICATION_SLOT</code> <em class="replaceable"><code>slot_name</code></em> [ <code class="literal">TEMPORARY</code> ] { <code class="literal">PHYSICAL</code> [ <code class="literal">RESERVE_WAL</code> ] | <code class="literal">LOGICAL</code> <em class="replaceable"><code>output_plugin</code></em> [ <code class="literal">EXPORT_SNAPSHOT</code> | <code class="literal">NOEXPORT_SNAPSHOT</code> | <code class="literal">USE_SNAPSHOT</code> ] }
  87. <a id="id-1.10.5.9.7.1.4.1.11" class="indexterm"></a>
  88. </span></dt><dd><p>
  89. Create a physical or logical replication
  90. slot. See <a class="xref" href="warm-standby.html#STREAMING-REPLICATION-SLOTS" title="26.2.6. Replication Slots">Section 26.2.6</a> for more about
  91. replication slots.
  92. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>slot_name</code></em></span></dt><dd><p>
  93. The name of the slot to create. Must be a valid replication slot
  94. name (see <a class="xref" href="warm-standby.html#STREAMING-REPLICATION-SLOTS-MANIPULATION" title="26.2.6.1. Querying and Manipulating Replication Slots">Section 26.2.6.1</a>).
  95. </p></dd><dt><span class="term"><em class="replaceable"><code>output_plugin</code></em></span></dt><dd><p>
  96. The name of the output plugin used for logical decoding
  97. (see <a class="xref" href="logicaldecoding-output-plugin.html" title="48.6. Logical Decoding Output Plugins">Section 48.6</a>).
  98. </p></dd><dt><span class="term"><code class="literal">TEMPORARY</code></span></dt><dd><p>
  99. Specify that this replication slot is a temporary one. Temporary
  100. slots are not saved to disk and are automatically dropped on error
  101. or when the session has finished.
  102. </p></dd><dt><span class="term"><code class="literal">RESERVE_WAL</code></span></dt><dd><p>
  103. Specify that this physical replication slot reserves <acronym class="acronym">WAL</acronym>
  104. immediately. Otherwise, <acronym class="acronym">WAL</acronym> is only reserved upon
  105. connection from a streaming replication client.
  106. </p></dd><dt><span class="term"><code class="literal">EXPORT_SNAPSHOT</code><br /></span><span class="term"><code class="literal">NOEXPORT_SNAPSHOT</code><br /></span><span class="term"><code class="literal">USE_SNAPSHOT</code></span></dt><dd><p>
  107. Decides what to do with the snapshot created during logical slot
  108. initialization. <code class="literal">EXPORT_SNAPSHOT</code>, which is the default,
  109. will export the snapshot for use in other sessions. This option can't
  110. be used inside a transaction. <code class="literal">USE_SNAPSHOT</code> will use the
  111. snapshot for the current transaction executing the command. This
  112. option must be used in a transaction, and
  113. <code class="literal">CREATE_REPLICATION_SLOT</code> must be the first command
  114. run in that transaction. Finally, <code class="literal">NOEXPORT_SNAPSHOT</code> will
  115. just use the snapshot for logical decoding as normal but won't do
  116. anything else with it.
  117. </p></dd></dl></div><p>
  118. In response to this command, the server will send a one-row result set
  119. containing the following fields:
  120. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">slot_name</code> (<code class="type">text</code>)</span></dt><dd><p>
  121. The name of the newly-created replication slot.
  122. </p></dd><dt><span class="term"><code class="literal">consistent_point</code> (<code class="type">text</code>)</span></dt><dd><p>
  123. The WAL location at which the slot became consistent. This is the
  124. earliest location from which streaming can start on this replication
  125. slot.
  126. </p></dd><dt><span class="term"><code class="literal">snapshot_name</code> (<code class="type">text</code>)</span></dt><dd><p>
  127. The identifier of the snapshot exported by the command. The
  128. snapshot is valid until a new command is executed on this connection
  129. or the replication connection is closed. Null if the created slot
  130. is physical.
  131. </p></dd><dt><span class="term"><code class="literal">output_plugin</code> (<code class="type">text</code>)</span></dt><dd><p>
  132. The name of the output plugin used by the newly-created replication
  133. slot. Null if the created slot is physical.
  134. </p></dd></dl></div><p>
  135. </p></dd><dt><span class="term"><code class="literal">START_REPLICATION</code> [ <code class="literal">SLOT</code> <em class="replaceable"><code>slot_name</code></em> ] [ <code class="literal">PHYSICAL</code> ] <em class="replaceable"><code>XXX/XXX</code></em> [ <code class="literal">TIMELINE</code> <em class="replaceable"><code>tli</code></em> ]
  136. <a id="id-1.10.5.9.7.1.5.1.8" class="indexterm"></a>
  137. </span></dt><dd><p>
  138. Instructs server to start streaming WAL, starting at
  139. WAL location <em class="replaceable"><code>XXX/XXX</code></em>.
  140. If <code class="literal">TIMELINE</code> option is specified,
  141. streaming starts on timeline <em class="replaceable"><code>tli</code></em>;
  142. otherwise, the server's current timeline is selected. The server can
  143. reply with an error, for example if the requested section of WAL has already
  144. been recycled. On success, server responds with a CopyBothResponse
  145. message, and then starts to stream WAL to the frontend.
  146. </p><p>
  147. If a slot's name is provided
  148. via <em class="replaceable"><code>slot_name</code></em>, it will be updated
  149. as replication progresses so that the server knows which WAL segments,
  150. and if <code class="varname">hot_standby_feedback</code> is on which transactions,
  151. are still needed by the standby.
  152. </p><p>
  153. If the client requests a timeline that's not the latest but is part of
  154. the history of the server, the server will stream all the WAL on that
  155. timeline starting from the requested start point up to the point where
  156. the server switched to another timeline. If the client requests
  157. streaming at exactly the end of an old timeline, the server responds
  158. immediately with CommandComplete without entering COPY mode.
  159. </p><p>
  160. After streaming all the WAL on a timeline that is not the latest one,
  161. the server will end streaming by exiting the COPY mode. When the client
  162. acknowledges this by also exiting COPY mode, the server sends a result
  163. set with one row and two columns, indicating the next timeline in this
  164. server's history. The first column is the next timeline's ID (type <code class="type">int8</code>), and the
  165. second column is the WAL location where the switch happened (type <code class="type">text</code>). Usually,
  166. the switch position is the end of the WAL that was streamed, but there
  167. are corner cases where the server can send some WAL from the old
  168. timeline that it has not itself replayed before promoting. Finally, the
  169. server sends CommandComplete message, and is ready to accept a new
  170. command.
  171. </p><p>
  172. WAL data is sent as a series of CopyData messages. (This allows
  173. other information to be intermixed; in particular the server can send
  174. an ErrorResponse message if it encounters a failure after beginning
  175. to stream.) The payload of each CopyData message from server to the
  176. client contains a message of one of the following formats:
  177. </p><p>
  178. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  179. XLogData (B)
  180. </span></dt><dd><p>
  181. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  182. Byte1('w')
  183. </span></dt><dd><p>
  184. Identifies the message as WAL data.
  185. </p></dd><dt><span class="term">
  186. Int64
  187. </span></dt><dd><p>
  188. The starting point of the WAL data in this message.
  189. </p></dd><dt><span class="term">
  190. Int64
  191. </span></dt><dd><p>
  192. The current end of WAL on the server.
  193. </p></dd><dt><span class="term">
  194. Int64
  195. </span></dt><dd><p>
  196. The server's system clock at the time of transmission, as
  197. microseconds since midnight on 2000-01-01.
  198. </p></dd><dt><span class="term">
  199. Byte<em class="replaceable"><code>n</code></em>
  200. </span></dt><dd><p>
  201. A section of the WAL data stream.
  202. </p><p>
  203. A single WAL record is never split across two XLogData messages.
  204. When a WAL record crosses a WAL page boundary, and is therefore
  205. already split using continuation records, it can be split at the page
  206. boundary. In other words, the first main WAL record and its
  207. continuation records can be sent in different XLogData messages.
  208. </p></dd></dl></div><p>
  209. </p></dd><dt><span class="term">
  210. Primary keepalive message (B)
  211. </span></dt><dd><p>
  212. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  213. Byte1('k')
  214. </span></dt><dd><p>
  215. Identifies the message as a sender keepalive.
  216. </p></dd><dt><span class="term">
  217. Int64
  218. </span></dt><dd><p>
  219. The current end of WAL on the server.
  220. </p></dd><dt><span class="term">
  221. Int64
  222. </span></dt><dd><p>
  223. The server's system clock at the time of transmission, as
  224. microseconds since midnight on 2000-01-01.
  225. </p></dd><dt><span class="term">
  226. Byte1
  227. </span></dt><dd><p>
  228. 1 means that the client should reply to this message as soon as
  229. possible, to avoid a timeout disconnect. 0 otherwise.
  230. </p></dd></dl></div><p>
  231. </p></dd></dl></div><p>
  232. </p><p>
  233. The receiving process can send replies back to the sender at any time,
  234. using one of the following message formats (also in the payload of a
  235. CopyData message):
  236. </p><p>
  237. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  238. Standby status update (F)
  239. </span></dt><dd><p>
  240. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  241. Byte1('r')
  242. </span></dt><dd><p>
  243. Identifies the message as a receiver status update.
  244. </p></dd><dt><span class="term">
  245. Int64
  246. </span></dt><dd><p>
  247. The location of the last WAL byte + 1 received and written to disk
  248. in the standby.
  249. </p></dd><dt><span class="term">
  250. Int64
  251. </span></dt><dd><p>
  252. The location of the last WAL byte + 1 flushed to disk in
  253. the standby.
  254. </p></dd><dt><span class="term">
  255. Int64
  256. </span></dt><dd><p>
  257. The location of the last WAL byte + 1 applied in the standby.
  258. </p></dd><dt><span class="term">
  259. Int64
  260. </span></dt><dd><p>
  261. The client's system clock at the time of transmission, as
  262. microseconds since midnight on 2000-01-01.
  263. </p></dd><dt><span class="term">
  264. Byte1
  265. </span></dt><dd><p>
  266. If 1, the client requests the server to reply to this message
  267. immediately. This can be used to ping the server, to test if
  268. the connection is still healthy.
  269. </p></dd></dl></div><p>
  270. </p></dd></dl></div><p>
  271. </p><p>
  272. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  273. Hot Standby feedback message (F)
  274. </span></dt><dd><p>
  275. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
  276. Byte1('h')
  277. </span></dt><dd><p>
  278. Identifies the message as a Hot Standby feedback message.
  279. </p></dd><dt><span class="term">
  280. Int64
  281. </span></dt><dd><p>
  282. The client's system clock at the time of transmission, as
  283. microseconds since midnight on 2000-01-01.
  284. </p></dd><dt><span class="term">
  285. Int32
  286. </span></dt><dd><p>
  287. The standby's current global xmin, excluding the catalog_xmin from any
  288. replication slots. If both this value and the following
  289. catalog_xmin are 0 this is treated as a notification that Hot Standby
  290. feedback will no longer be sent on this connection. Later non-zero
  291. messages may reinitiate the feedback mechanism.
  292. </p></dd><dt><span class="term">
  293. Int32
  294. </span></dt><dd><p>
  295. The epoch of the global xmin xid on the standby.
  296. </p></dd><dt><span class="term">
  297. Int32
  298. </span></dt><dd><p>
  299. The lowest catalog_xmin of any replication slots on the standby. Set to 0
  300. if no catalog_xmin exists on the standby or if hot standby feedback is being
  301. disabled.
  302. </p></dd><dt><span class="term">
  303. Int32
  304. </span></dt><dd><p>
  305. The epoch of the catalog_xmin xid on the standby.
  306. </p></dd></dl></div><p>
  307. </p></dd></dl></div><p>
  308. </p></dd><dt><span class="term"><code class="literal">START_REPLICATION</code> <code class="literal">SLOT</code> <em class="replaceable"><code>slot_name</code></em> <code class="literal">LOGICAL</code> <em class="replaceable"><code>XXX/XXX</code></em> [ ( <em class="replaceable"><code>option_name</code></em> [ <em class="replaceable"><code>option_value</code></em> ] [, ...] ) ]</span></dt><dd><p>
  309. Instructs server to start streaming WAL for logical replication, starting
  310. at WAL location <em class="replaceable"><code>XXX/XXX</code></em>. The server can
  311. reply with an error, for example if the requested section of WAL has already
  312. been recycled. On success, server responds with a CopyBothResponse
  313. message, and then starts to stream WAL to the frontend.
  314. </p><p>
  315. The messages inside the CopyBothResponse messages are of the same format
  316. documented for <code class="literal">START_REPLICATION ... PHYSICAL</code>.
  317. </p><p>
  318. The output plugin associated with the selected slot is used
  319. to process the output for streaming.
  320. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">SLOT</code> <em class="replaceable"><code>slot_name</code></em></span></dt><dd><p>
  321. The name of the slot to stream changes from. This parameter is required,
  322. and must correspond to an existing logical replication slot created
  323. with <code class="literal">CREATE_REPLICATION_SLOT</code> in
  324. <code class="literal">LOGICAL</code> mode.
  325. </p></dd><dt><span class="term"><em class="replaceable"><code>XXX/XXX</code></em></span></dt><dd><p>
  326. The WAL location to begin streaming at.
  327. </p></dd><dt><span class="term"><em class="replaceable"><code>option_name</code></em></span></dt><dd><p>
  328. The name of an option passed to the slot's logical decoding plugin.
  329. </p></dd><dt><span class="term"><em class="replaceable"><code>option_value</code></em></span></dt><dd><p>
  330. Optional value, in the form of a string constant, associated with the
  331. specified option.
  332. </p></dd></dl></div></dd><dt><span class="term">
  333. <code class="literal">DROP_REPLICATION_SLOT</code> <em class="replaceable"><code>slot_name</code></em> [<span class="optional"> <code class="literal">WAIT</code> </span>]
  334. <a id="id-1.10.5.9.7.1.7.1.4" class="indexterm"></a>
  335. </span></dt><dd><p>
  336. Drops a replication slot, freeing any reserved server-side resources.
  337. If the slot is a logical slot that was created in a database other than
  338. the database the walsender is connected to, this command fails.
  339. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>slot_name</code></em></span></dt><dd><p>
  340. The name of the slot to drop.
  341. </p></dd><dt><span class="term"><code class="literal">WAIT</code></span></dt><dd><p>
  342. This option causes the command to wait if the slot is active until
  343. it becomes inactive, instead of the default behavior of raising an
  344. error.
  345. </p></dd></dl></div></dd><dt><span class="term"><code class="literal">BASE_BACKUP</code> [ <code class="literal">LABEL</code> <em class="replaceable"><code>'label'</code></em> ] [ <code class="literal">PROGRESS</code> ] [ <code class="literal">FAST</code> ] [ <code class="literal">WAL</code> ] [ <code class="literal">NOWAIT</code> ] [ <code class="literal">MAX_RATE</code> <em class="replaceable"><code>rate</code></em> ] [ <code class="literal">TABLESPACE_MAP</code> ] [ <code class="literal">NOVERIFY_CHECKSUMS</code> ]
  346. <a id="id-1.10.5.9.7.1.8.1.12" class="indexterm"></a>
  347. </span></dt><dd><p>
  348. Instructs the server to start streaming a base backup.
  349. The system will automatically be put in backup mode before the backup
  350. is started, and taken out of it when the backup is complete. The
  351. following options are accepted:
  352. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">LABEL</code> <em class="replaceable"><code>'label'</code></em></span></dt><dd><p>
  353. Sets the label of the backup. If none is specified, a backup label
  354. of <code class="literal">base backup</code> will be used. The quoting rules
  355. for the label are the same as a standard SQL string with
  356. <a class="xref" href="runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS">standard_conforming_strings</a> turned on.
  357. </p></dd><dt><span class="term"><code class="literal">PROGRESS</code></span></dt><dd><p>
  358. Request information required to generate a progress report. This will
  359. send back an approximate size in the header of each tablespace, which
  360. can be used to calculate how far along the stream is done. This is
  361. calculated by enumerating all the file sizes once before the transfer
  362. is even started, and might as such have a negative impact on the
  363. performance. In particular, it might take longer before the first data
  364. is streamed. Since the database files can change during the backup,
  365. the size is only approximate and might both grow and shrink between
  366. the time of approximation and the sending of the actual files.
  367. </p></dd><dt><span class="term"><code class="literal">FAST</code></span></dt><dd><p>
  368. Request a fast checkpoint.
  369. </p></dd><dt><span class="term"><code class="literal">WAL</code></span></dt><dd><p>
  370. Include the necessary WAL segments in the backup. This will include
  371. all the files between start and stop backup in the
  372. <code class="filename">pg_wal</code> directory of the base directory tar
  373. file.
  374. </p></dd><dt><span class="term"><code class="literal">NOWAIT</code></span></dt><dd><p>
  375. By default, the backup will wait until the last required WAL
  376. segment has been archived, or emit a warning if log archiving is
  377. not enabled. Specifying <code class="literal">NOWAIT</code> disables both
  378. the waiting and the warning, leaving the client responsible for
  379. ensuring the required log is available.
  380. </p></dd><dt><span class="term"><code class="literal">MAX_RATE</code> <em class="replaceable"><code>rate</code></em></span></dt><dd><p>
  381. Limit (throttle) the maximum amount of data transferred from server
  382. to client per unit of time. The expected unit is kilobytes per second.
  383. If this option is specified, the value must either be equal to zero
  384. or it must fall within the range from 32 kB through 1 GB (inclusive).
  385. If zero is passed or the option is not specified, no restriction is
  386. imposed on the transfer.
  387. </p></dd><dt><span class="term"><code class="literal">TABLESPACE_MAP</code></span></dt><dd><p>
  388. Include information about symbolic links present in the directory
  389. <code class="filename">pg_tblspc</code> in a file named
  390. <code class="filename">tablespace_map</code>. The tablespace map file includes
  391. each symbolic link name as it exists in the directory
  392. <code class="filename">pg_tblspc/</code> and the full path of that symbolic link.
  393. </p></dd><dt><span class="term"><code class="literal">NOVERIFY_CHECKSUMS</code></span></dt><dd><p>
  394. By default, checksums are verified during a base backup if they are
  395. enabled. Specifying <code class="literal">NOVERIFY_CHECKSUMS</code> disables
  396. this verification.
  397. </p></dd></dl></div><p>
  398. </p><p>
  399. When the backup is started, the server will first send two
  400. ordinary result sets, followed by one or more CopyResponse
  401. results.
  402. </p><p>
  403. The first ordinary result set contains the starting position of the
  404. backup, in a single row with two columns. The first column contains
  405. the start position given in XLogRecPtr format, and the second column
  406. contains the corresponding timeline ID.
  407. </p><p>
  408. The second ordinary result set has one row for each tablespace.
  409. The fields in this row are:
  410. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">spcoid</code> (<code class="type">oid</code>)</span></dt><dd><p>
  411. The OID of the tablespace, or null if it's the base
  412. directory.
  413. </p></dd><dt><span class="term"><code class="literal">spclocation</code> (<code class="type">text</code>)</span></dt><dd><p>
  414. The full path of the tablespace directory, or null
  415. if it's the base directory.
  416. </p></dd><dt><span class="term"><code class="literal">size</code> (<code class="type">int8</code>)</span></dt><dd><p>
  417. The approximate size of the tablespace, if progress report has
  418. been requested; otherwise it's null.
  419. </p></dd></dl></div><p>
  420. </p><p>
  421. After the second regular result set, one or more CopyResponse results
  422. will be sent, one for the main data directory and one for each additional tablespace other
  423. than <code class="literal">pg_default</code> and <code class="literal">pg_global</code>. The data in
  424. the CopyResponse results will be a tar format (following the
  425. <span class="quote">“<span class="quote">ustar interchange format</span>”</span> specified in the POSIX 1003.1-2008
  426. standard) dump of the tablespace contents, except that the two trailing
  427. blocks of zeroes specified in the standard are omitted.
  428. After the tar data is complete, a final ordinary result set will be sent,
  429. containing the WAL end position of the backup, in the same format as
  430. the start position.
  431. </p><p>
  432. The tar archive for the data directory and each tablespace will contain
  433. all files in the directories, regardless of whether they are
  434. <span class="productname">PostgreSQL</span> files or other files added to the same
  435. directory. The only excluded files are:
  436. </p><div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc"><p>
  437. <code class="filename">postmaster.pid</code>
  438. </p></li><li class="listitem" style="list-style-type: disc"><p>
  439. <code class="filename">postmaster.opts</code>
  440. </p></li><li class="listitem" style="list-style-type: disc"><p>
  441. <code class="filename">pg_internal.init</code> (found in multiple directories)
  442. </p></li><li class="listitem" style="list-style-type: disc"><p>
  443. Various temporary files and directories created during the operation
  444. of the PostgreSQL server, such as any file or directory beginning
  445. with <code class="filename">pgsql_tmp</code> and temporary relations.
  446. </p></li><li class="listitem" style="list-style-type: disc"><p>
  447. Unlogged relations, except for the init fork which is required to
  448. recreate the (empty) unlogged relation on recovery.
  449. </p></li><li class="listitem" style="list-style-type: disc"><p>
  450. <code class="filename">pg_wal</code>, including subdirectories. If the backup is run
  451. with WAL files included, a synthesized version of <code class="filename">pg_wal</code> will be
  452. included, but it will only contain the files necessary for the
  453. backup to work, not the rest of the contents.
  454. </p></li><li class="listitem" style="list-style-type: disc"><p>
  455. <code class="filename">pg_dynshmem</code>, <code class="filename">pg_notify</code>,
  456. <code class="filename">pg_replslot</code>, <code class="filename">pg_serial</code>,
  457. <code class="filename">pg_snapshots</code>, <code class="filename">pg_stat_tmp</code>, and
  458. <code class="filename">pg_subtrans</code> are copied as empty directories (even if
  459. they are symbolic links).
  460. </p></li><li class="listitem" style="list-style-type: disc"><p>
  461. Files other than regular files and directories, such as symbolic
  462. links (other than for the directories listed above) and special
  463. device files, are skipped. (Symbolic links
  464. in <code class="filename">pg_tblspc</code> are maintained.)
  465. </p></li></ul></div><p>
  466. Owner, group, and file mode are set if the underlying file system on
  467. the server supports it.
  468. </p></dd></dl></div><p>
  469. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sasl-authentication.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="protocol.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="protocol-logical-replication.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.3. SASL Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 52.5. Logical Streaming Replication Protocol</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1