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.

99 line
8.7KB

  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>30.2. Subscription</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="logical-replication-publication.html" title="30.1. Publication" /><link rel="next" href="logical-replication-conflicts.html" title="30.3. Conflicts" /></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">30.2. Subscription</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="logical-replication-publication.html" title="30.1. Publication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="logical-replication.html" title="Chapter 30. Logical Replication">Up</a></td><th width="60%" align="center">Chapter 30. Logical Replication</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="logical-replication-conflicts.html" title="30.3. Conflicts">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="LOGICAL-REPLICATION-SUBSCRIPTION"><div class="titlepage"><div><div><h2 class="title" style="clear: both">30.2. Subscription</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="logical-replication-subscription.html#LOGICAL-REPLICATION-SUBSCRIPTION-SLOT">30.2.1. Replication Slot Management</a></span></dt></dl></div><p>
  3. A <em class="firstterm">subscription</em> is the downstream side of logical
  4. replication. The node where a subscription is defined is referred to as
  5. the <em class="firstterm">subscriber</em>. A subscription defines the connection
  6. to another database and set of publications (one or more) to which it wants
  7. to subscribe.
  8. </p><p>
  9. The subscriber database behaves in the same way as any other PostgreSQL
  10. instance and can be used as a publisher for other databases by defining its
  11. own publications.
  12. </p><p>
  13. A subscriber node may have multiple subscriptions if desired. It is
  14. possible to define multiple subscriptions between a single
  15. publisher-subscriber pair, in which case care must be taken to ensure
  16. that the subscribed publication objects don't overlap.
  17. </p><p>
  18. Each subscription will receive changes via one replication slot (see
  19. <a class="xref" href="warm-standby.html#STREAMING-REPLICATION-SLOTS" title="26.2.6. Replication Slots">Section 26.2.6</a>). Additional temporary
  20. replication slots may be required for the initial data synchronization
  21. of pre-existing table data.
  22. </p><p>
  23. A logical replication subscription can be a standby for synchronous
  24. replication (see <a class="xref" href="warm-standby.html#SYNCHRONOUS-REPLICATION" title="26.2.8. Synchronous Replication">Section 26.2.8</a>). The standby
  25. name is by default the subscription name. An alternative name can be
  26. specified as <code class="literal">application_name</code> in the connection
  27. information of the subscription.
  28. </p><p>
  29. Subscriptions are dumped by <code class="command">pg_dump</code> if the current user
  30. is a superuser. Otherwise a warning is written and subscriptions are
  31. skipped, because non-superusers cannot read all subscription information
  32. from the <code class="structname">pg_subscription</code> catalog.
  33. </p><p>
  34. The subscription is added using <a class="xref" href="sql-createsubscription.html" title="CREATE SUBSCRIPTION"><span class="refentrytitle">CREATE SUBSCRIPTION</span></a> and
  35. can be stopped/resumed at any time using the
  36. <a class="xref" href="sql-altersubscription.html" title="ALTER SUBSCRIPTION"><span class="refentrytitle">ALTER SUBSCRIPTION</span></a> command and removed using
  37. <a class="xref" href="sql-dropsubscription.html" title="DROP SUBSCRIPTION"><span class="refentrytitle">DROP SUBSCRIPTION</span></a>.
  38. </p><p>
  39. When a subscription is dropped and recreated, the synchronization
  40. information is lost. This means that the data has to be resynchronized
  41. afterwards.
  42. </p><p>
  43. The schema definitions are not replicated, and the published tables must
  44. exist on the subscriber. Only regular tables may be
  45. the target of replication. For example, you can't replicate to a view.
  46. </p><p>
  47. The tables are matched between the publisher and the subscriber using the
  48. fully qualified table name. Replication to differently-named tables on the
  49. subscriber is not supported.
  50. </p><p>
  51. Columns of a table are also matched by name. The order of columns in the
  52. subscriber table does not need to match that of the publisher. The data
  53. types of the columns do not need to match, as long as the text
  54. representation of the data can be converted to the target type. For
  55. example, you can replicate from a column of type <code class="type">integer</code> to a
  56. column of type <code class="type">bigint</code>. The target table can also have
  57. additional columns not provided by the published table. Any such columns
  58. will be filled with the default value as specified in the definition of the
  59. target table.
  60. </p><div class="sect2" id="LOGICAL-REPLICATION-SUBSCRIPTION-SLOT"><div class="titlepage"><div><div><h3 class="title">30.2.1. Replication Slot Management</h3></div></div></div><p>
  61. As mentioned earlier, each (active) subscription receives changes from a
  62. replication slot on the remote (publishing) side. Normally, the remote
  63. replication slot is created automatically when the subscription is created
  64. using <code class="command">CREATE SUBSCRIPTION</code> and it is dropped
  65. automatically when the subscription is dropped using <code class="command">DROP
  66. SUBSCRIPTION</code>. In some situations, however, it can be useful or
  67. necessary to manipulate the subscription and the underlying replication
  68. slot separately. Here are some scenarios:
  69. </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
  70. When creating a subscription, the replication slot already exists. In
  71. that case, the subscription can be created using
  72. the <code class="literal">create_slot = false</code> option to associate with the
  73. existing slot.
  74. </p></li><li class="listitem"><p>
  75. When creating a subscription, the remote host is not reachable or in an
  76. unclear state. In that case, the subscription can be created using
  77. the <code class="literal">connect = false</code> option. The remote host will then not
  78. be contacted at all. This is what <span class="application">pg_dump</span>
  79. uses. The remote replication slot will then have to be created
  80. manually before the subscription can be activated.
  81. </p></li><li class="listitem"><p>
  82. When dropping a subscription, the replication slot should be kept.
  83. This could be useful when the subscriber database is being moved to a
  84. different host and will be activated from there. In that case,
  85. disassociate the slot from the subscription using <code class="command">ALTER
  86. SUBSCRIPTION</code> before attempting to drop the subscription.
  87. </p></li><li class="listitem"><p>
  88. When dropping a subscription, the remote host is not reachable. In
  89. that case, disassociate the slot from the subscription
  90. using <code class="command">ALTER SUBSCRIPTION</code> before attempting to drop
  91. the subscription. If the remote database instance no longer exists, no
  92. further action is then necessary. If, however, the remote database
  93. instance is just unreachable, the replication slot should then be
  94. dropped manually; otherwise it would continue to reserve WAL and might
  95. eventually cause the disk to fill up. Such cases should be carefully
  96. investigated.
  97. </p></li></ul></div><p>
  98. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="logical-replication-publication.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="logical-replication.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="logical-replication-conflicts.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">30.1. Publication </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 30.3. Conflicts</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1