Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f7bf0dd

Browse files
committed
Merge branch 'PGPROEE9_6_MULTIMASTER' of https://gitlab.postgrespro.ru/pgpro-dev/postgrespro into PGPROEE9_6_MULTIMASTER
2 parents ac1296c + 71cbfa7 commit f7bf0dd

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

doc/src/sgml/multimaster.sgml

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<title>multimaster</title>
33
<para>
44
<filename>multimaster</filename> is a <productname>&productname;</productname> extension with a set
5-
of patches that turns <productname>PostgreSQL</productname> into a synchronous shared-nothing
5+
of patches that turns <productname>&productname;</productname> into a synchronous shared-nothing
66
cluster to provide Online Transaction Processing (<acronym>OLTP</acronym>) scalability for read transactions and high availability with automatic disaster recovery.</para>
77
<para> As compared to a standard <productname>PostgreSQL</productname> master-slave cluster, a cluster configured with the <filename>multimaster</filename> extension offers the following benefits:</para>
88
<itemizedlist>
@@ -47,7 +47,7 @@
4747
<para>
4848
To ensure high availability and fault tolerance of the cluster,
4949
<filename>multimaster</filename> uses three-phase commit protocol
50-
and heartbeats for failure discovery. A multi-master cluster of N
50+
and heartbeats for failure discovery. A multi-master cluster of <replaceable>N</replaceable>
5151
nodes can continue working while the majority of the nodes are
5252
alive and reachable by other nodes. When the node is reconnected
5353
to the cluster, <filename>multimaster</filename> can automatically
@@ -79,22 +79,15 @@
7979
configure the cluster with <filename>multimaster</filename>. Suppose
8080
you are setting up a cluster of three nodes, with
8181
<literal>node1</literal>, <literal>node2</literal>, and
82-
<literal>node3</literal> domain names. To configure your cluster
83-
with <filename>multimaster</filename>, complete these steps on each
84-
cluster node:
85-
</para>
86-
<orderedlist>
87-
<listitem>
88-
<para>
89-
Set up the database to be replicated with
82+
<literal>node3</literal> domain names. First, set up the database to be replicated with
9083
<filename>multimaster</filename>:
9184
</para>
9285
<itemizedlist>
9386
<listitem>
9487
<para>
9588
If you are starting from scratch, initialize a cluster,
9689
create an empty database <literal>mydb</literal> and a new
97-
user <literal>myuser</literal>, as usual. For details, see <xref linkend="creating-cluster">.
90+
user <literal>myuser</literal>, as usual. For details, see <xref linkend="creating-cluster">.
9891
</para>
9992
</listitem>
10093
<listitem>
@@ -104,26 +97,34 @@
10497
new nodes from the working node using
10598
<literal>pg_basebackup</literal>. On each cluster node you
10699
are going to add, run:
107-
</para>
108100
<programlisting>
109-
pg_basebackup -D ./datadir -h node1 mydb
101+
pg_basebackup -D <replaceable>datadir</> -h node1 mydb
110102
</programlisting>
103+
</para>
111104
<para>
112105
For details on using <literal>pg_basebackup</literal>, see
113106
<xref linkend="app-pgbasebackup">.
114107
</para>
115108
</listitem>
116109
</itemizedlist>
117-
</listitem>
110+
<para>Once the database is set up for replication, complete the following steps on each
111+
cluster node:
112+
</para>
113+
<orderedlist>
118114
<listitem>
119115
<para>
120116
Modify the <literal>postgresql.conf</literal> configuration
121117
file, as follows:
122118
</para>
123119
<itemizedlist>
120+
<listitem><para>Add <literal>multimaster</literal> to the <varname>shared_preload_libraries</varname> variable:</para>
121+
<programlisting>
122+
shared_preload_libraries = 'multimaster'
123+
</programlisting>
124+
</listitem>
124125
<listitem><para>Change transaction isolation level to <literal>repeatable read</literal>:
125126
<programlisting>
126-
default_transaction_isolation = "repeatable read"</programlisting>
127+
default_transaction_isolation = 'repeatable read'</programlisting>
127128
<filename>multimaster</filename> supports only the <literal>repeatable read</literal> isolation level. You cannot set up <filename>multimaster</filename> with the default <literal>read committed</literal> level.
128129
</para>
129130
</listitem>
@@ -142,12 +143,12 @@ max_replication_slots = 10 # at least the number of nodes
142143
You must change the replication level to
143144
<literal>logical</literal> as
144145
<filename>multimaster</filename> relies on logical
145-
replication. For a cluster of N nodes, enable at least N
146+
replication. For a cluster of <replaceable>N</replaceable> nodes, enable at least <replaceable>N</replaceable>
146147
WAL sender processes and replication slots. Since
147148
<filename>multimaster</filename> implicitly adds a
148149
<literal>PREPARE</literal> phase to each
149150
<literal>COMMIT</literal> transaction, make sure to set
150-
the number of prepared transactions to N*<varname>max_connections</varname>.
151+
the number of prepared transactions to <replaceable>N</replaceable>*<varname>max_connections</varname>.
151152
Otherwise, prepared transactions may be queued.
152153
</para>
153154
</listitem>
@@ -178,11 +179,12 @@ max_worker_processes = 250
178179
</para>
179180
<programlisting>
180181
multimaster.max_nodes = 3 # cluster size
181-
multimaster.node_id = 1 # the 1-based index of the node
182+
multimaster.node_id = 1 # the 1-based index of this node
182183
# in the cluster
183184
multimaster.conn_strings = 'dbname=mydb user=myuser host=node1, dbname=mydb user=myuser host=node2, dbname=mydb user=myuser host=node3'
184-
# comma-separated list of connection
185-
# strings to neighbor nodes
185+
# comma-separated list
186+
# of connection strings
187+
# to neighbor nodes
186188
</programlisting>
187189
<important><para>The
188190
<literal>node_id</literal> variable takes natural
@@ -218,10 +220,10 @@ host replication all node3 trust
218220
</listitem>
219221
<listitem>
220222
<para>
221-
Start <productname>PostgreSQL</productname>:
223+
Restart <productname>PostgreSQL</productname>:
222224
</para>
223225
<programlisting>
224-
pg_ctl -D ./datadir -l ./pg.log start
226+
pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable> start
225227
</programlisting>
226228
</listitem>
227229
</orderedlist>
@@ -241,7 +243,7 @@ SELECT * FROM mtm.get_cluster_state();
241243
</programlisting>
242244
<para>
243245
If <literal>liveNodes</literal> is equal to
244-
<literal>allNodes</literal>, you cluster is successfully
246+
<literal>allNodes</literal>, your cluster is successfully
245247
configured and ready to use. </para>
246248
<para><emphasis role="strong">See Also</emphasis></para>
247249
<para><link linkend="multimaster-tuning-configuration-parameters">Tuning
@@ -333,7 +335,7 @@ SELECT * FROM mtm.get_cluster_state();
333335
</sect4>
334336
</sect3>
335337
</sect2>
336-
<sect2 id="multimaster-usage" xreflabel="Using multimaster for Data Replication">
338+
<sect2 id="multimaster-usage">
337339
<title>Using multimaster for Data Replication</title>
338340
<para>The <filename>multimaster</filename> extension takes care of the database replication in a fully automated way. You can perform write transactions on any node, and work with temporary tables on each cluster node simultaneosly. However, make sure to take the following replication restrictions into account:</para>
339341
<itemizedlist>
@@ -345,8 +347,8 @@ SELECT * FROM mtm.get_cluster_state();
345347
</listitem>
346348
<listitem>
347349
<para>
348-
The replicated tables must have primary keys or replica identity. By default,
349-
<filename>multimaster</filename> does not allow replication for such tables
350+
The replicated tables must have primary keys or replica identity. Otherwise,
351+
<filename>multimaster</filename> will not allow replication
350352
because of the logical replication restrictions. Unlogged tables are not replicated, as in the standard <productname>PostgreSQL</productname>.
351353
</para>
352354
<note><para>You can enable replication
@@ -475,7 +477,7 @@ SELECT * FROM mtm.add_node('dbname=mydb user=myuser host=node4');
475477
Connect to the new node and clone all the data from one of the alive nodes to the new node:
476478
</para>
477479
<programlisting>
478-
pg_basebackup -D ./datadir -h node1 -x
480+
pg_basebackup -D <replaceable>datadir</replaceable> -h node1 -x
479481
</programlisting>
480482
<para>
481483
<literal>pg_basebackup</literal> copies the entire data
@@ -499,7 +501,7 @@ multimaster.conn_strings = 'dbname=mydb user=myuser host=node1, dbname=mydb user
499501
Start <productname>PostgreSQL</productname> on the new node:
500502
</para>
501503
<programlisting>
502-
pg_ctl -D ./datadir -l ./pg.log start
504+
pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable> start
503505
</programlisting>
504506
<para>
505507
All the cluster nodes get locked for write transactions until the new node retrieves all the updates that happened after you started making a base backup.
@@ -541,7 +543,7 @@ pg_ctl -D ./datadir -l ./pg.log start
541543
SELECT mtm.stop_node(3);
542544
</programlisting>
543545
<para>
544-
This disables node 3 on all cluster nodes and stops replication to
546+
This disables replication slots for node 3 on all cluster nodes and stops replication to
545547
this node.
546548
</para>
547549
<para>
@@ -574,7 +576,7 @@ SELECT * FROM mtm.recover_node(2);
574576
Connect to <literal>node2</literal> and clone all the data from one of the alive nodes:
575577
</para>
576578
<programlisting>
577-
pg_basebackup -D ./datadir -h node1 -x
579+
pg_basebackup -D <replaceable>datadir</replaceable> -h node1 -x
578580
</programlisting>
579581
<para>
580582
<literal>pg_basebackup</literal> copies the entire data
@@ -587,7 +589,7 @@ pg_basebackup -D ./datadir -h node1 -x
587589
Start <productname>PostgreSQL</productname> on the restored node:
588590
</para>
589591
<programlisting>
590-
pg_ctl -D ./datadir -l ./pg.log start
592+
pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable> start
591593
</programlisting>
592594
<para>
593595
All the cluster nodes get locked for write transactions until the restored node retrieves all the updates that happened after you started making a base backup.
@@ -673,8 +675,7 @@ pg_ctl -D ./datadir -l ./pg.log start
673675
</para>
674676
<para>
675677
To complete the transaction, the arbiter must receive a response
676-
from the majority of the nodes. For example, for a cluster of 2N +
677-
1 nodes, at least N+1 responses are required. Thus, <filename>multimaster</filename> ensures that
678+
from the majority of the nodes. For example, for a cluster of 2<replaceable>N</replaceable>+1 nodes, at least <replaceable>N</replaceable>+1 responses are required. Thus, <filename>multimaster</filename> ensures that
678679
your cluster is available for reads and writes while the majority
679680
of the nodes are connected, and no data inconsistencies occur in
680681
case of a node or connection failure. For details on the failure
@@ -714,8 +715,8 @@ pg_ctl -D ./datadir -l ./pg.log start
714715
propagation information, <filename>multimaster</filename> will
715716
continue accepting writes at each node in the bigger partition,
716717
and deny all writes in the smaller one. Thus, a cluster consisting
717-
of 2N+1 nodes can tolerate N node failures and stay alive if any
718-
N+1 nodes are alive and connected to each other.
718+
of 2<replaceable>N</replaceable>+1 nodes can tolerate <replaceable>N</replaceable> node failures and stay alive if any
719+
<replaceable>N</replaceable>+1 nodes are alive and connected to each other.
719720
</para>
720721
<para>
721722
In case of a partial network split when different nodes have
@@ -839,7 +840,7 @@ pg_ctl -D ./datadir -l ./pg.log start
839840
This variable enables/disables replication of tables without primary
840841
keys. By default, such replication is
841842
disabled because of the logical replication restrictions. To enable
842-
replication of tables without primary keys, you can set this variable to false. However, take into
843+
replication of tables without primary keys, you can set this variable to <literal>false</literal>. However, take into
843844
account that <varname>multimaster</varname> does not allow update
844845
operations on such tables. </para><para>Default: true
845846
</para></listitem></varlistentry>
@@ -1100,7 +1101,7 @@ pg_ctl -D ./datadir -l ./pg.log start
11001101
</listitem>
11011102
<listitem>
11021103
<para>
1103-
<parameter>stalledNodeMask</parameter>, <type>biint</type>
1104+
<parameter>stalledNodeMask</parameter>, <type>bigint</type>
11041105
</para>
11051106
<para>Bitmask of nodes for which replication slots were dropped.
11061107
</para>

0 commit comments

Comments
 (0)