@@ -10,157 +10,85 @@ This tutorial is intended as a follow-up to the
10
10
It continues building on the examples from that page.
11
11
It is recommended that you complete the bootstrapping guide before you proceed.
12
12
13
+ .. _replication-add_replica_manual_failover :
14
+
15
+ Master-replica: manual failover
16
+ -------------------------------
17
+
18
+ For the :ref: `manual <replication-master_replica_bootstrap >` failover.
19
+
20
+ 1. Update ``instances.yml ``:
21
+
22
+ .. literalinclude :: /code_snippets/snippets/replication/instances.enabled/manual_leader/instances.yml
23
+ :language: yaml
24
+ :dedent:
25
+
26
+ 2. Add ``instance003 ``:
27
+
28
+ .. literalinclude :: /code_snippets/snippets/replication/instances.enabled/manual_leader/config.yaml
29
+ :language: yaml
30
+ :start-at: groups:
31
+ :end-at: listen: 127.0.0.1:3303
32
+ :dedent:
33
+
34
+ 3. Start: ``tt start manual_leader:instance003 ``, ``tt status manual_leader ``.
35
+
36
+ 4. ``tt connect manual_leader:instance001 ``.
37
+
38
+ ``box.info.election ``, ``box.space._cluster:select() ``.
39
+
40
+
41
+ .. _replication-add_replica_automated_failover :
42
+
43
+ Master-replica: automated failover
44
+ ----------------------------------
45
+
46
+ For the :ref: `automated <replication-master_replica_bootstrap_auto >` failover.
47
+
48
+
49
+ 1. Update ``instances.yml ``:
50
+
51
+ .. literalinclude :: /code_snippets/snippets/replication/instances.enabled/auto_leader/instances.yml
52
+ :language: yaml
53
+ :dedent:
54
+
55
+ 2. Add ``instance003 ``:
56
+
57
+ .. literalinclude :: /code_snippets/snippets/replication/instances.enabled/auto_leader/config.yaml
58
+ :language: yaml
59
+ :start-at: groups:
60
+ :end-at: listen: 127.0.0.1:3303
61
+ :dedent:
62
+
63
+ 3. Start: ``tt start auto_leader:instance003 ``, ``tt status auto_leader ``.
64
+
65
+ 4. ``tt connect auto_leader:instance001 ``.
66
+
67
+ ``box.info.election ``, ``box.space._cluster:select() ``.
68
+
69
+
70
+
13
71
14
- Adding a replica
15
- ----------------
16
-
17
- .. image :: mr-1m-2r-mesh-add.png
18
- :align: center
19
-
20
- To add a second **replica ** instance to the **master-replica ** set from our
21
- :ref: `bootstrapping example <replication-master_replica_bootstrap >`, we need an
22
- analog of the instance file that we created for the first replica in that set:
23
-
24
- .. code-block :: lua
25
-
26
- -- instance file for replica #2
27
- box.cfg{
28
- listen = 3301,
29
- replication = {'replicator:[email protected] :3301', -- master URI
30
- 'replicator:[email protected] :3301', -- replica #1 URI
31
- 'replicator:[email protected] :3301'}, -- replica #2 URI
32
- read_only = true
33
- }
34
- box.once("schema", function()
35
- box.schema.user.create('replicator', {password = 'password'})
36
- box.schema.user.grant('replicator', 'replication') -- grant replication role
37
- box.schema.space.create("test")
38
- box.space.test:create_index("primary")
39
- print('box.once executed on replica #2')
40
- end)
41
-
42
- Here we add the URI of replica #2 to the :ref: `replication <cfg_replication-replication >`
43
- parameter, so now it contains three URIs.
44
-
45
- After we launch the new replica instance, it gets connected to the master
46
- instance and retrieves the master's write-ahead-log and snapshot files:
47
-
48
- .. code-block :: console
49
-
50
- $ # launching replica #2
51
- $ tarantool replica2.lua
52
- 2017-06-14 14:54:33.927 [46945] main/101/replica2.lua C> version 1.7.4-52-g980d30092
53
- 2017-06-14 14:54:33.927 [46945] main/101/replica2.lua C> log level 5
54
- 2017-06-14 14:54:33.928 [46945] main/101/replica2.lua I> mapping 268435456 bytes for tuple arena...
55
- 2017-06-14 14:54:33.930 [46945] main/104/applier/[email protected] I> remote master is 1.7.4 at 192.168.0.101:3301
56
- 2017-06-14 14:54:33.930 [46945] main/104/applier/[email protected] I> authenticated
57
- 2017-06-14 14:54:33.930 [46945] main/101/replica2.lua I> bootstrapping replica from 192.168.0.101:3301
58
- 2017-06-14 14:54:33.933 [46945] main/104/applier/[email protected] I> initial data received
59
- 2017-06-14 14:54:33.933 [46945] main/104/applier/[email protected] I> final data received
60
- 2017-06-14 14:54:33.934 [46945] snapshot/101/main I> saving snapshot `/var/lib/tarantool/replica2/00000000000000000010.snap.inprogress'
61
- 2017-06-14 14:54:33.934 [46945] snapshot/101/main I> done
62
- 2017-06-14 14:54:33.935 [46945] main/101/replica2.lua I> vinyl checkpoint done
63
- 2017-06-14 14:54:33.935 [46945] main/101/replica2.lua I> ready to accept requests
64
- 2017-06-14 14:54:33.935 [46945] main/101/replica2.lua I> set 'read_only' configuration option to true
65
- 2017-06-14 14:54:33.936 [46945] main C> entering the event loop
66
-
67
- Since we are adding a read-only instance, there is no need to dynamically
68
- update the ``replication `` parameter on the other running instances. This update
69
- would be required if we :ref: `added a master instance <replication-add_master >`.
70
-
71
- However, we recommend specifying the URI of replica #3 in all instance files of the
72
- replica set. This will keep all the files consistent with each other and with
73
- the current replication topology, and so will help to avoid configuration errors
74
- in case of further configuration updates and replica set restart.
75
72
76
73
.. _replication-add_master :
77
74
78
- Adding a master
79
- ---------------
80
-
81
- .. image :: mm-3m-mesh-add.png
82
- :align: center
83
-
84
- To add a third master instance to the **master-master ** set from our
85
- :ref: `bootstrapping example <replication-master_master_bootstrap >`, we need an
86
- analog of the instance files that we created to bootstrap the other master
87
- instances in that set:
88
-
89
- .. code-block :: lua
90
-
91
- -- instance file for master #3
92
- box.cfg{
93
- listen = 3301,
94
- replication = {'replicator:[email protected] :3301', -- master#1 URI
95
- 'replicator:[email protected] :3301', -- master#2 URI
96
- 'replicator:[email protected] :3301'}, -- master#3 URI
97
- read_only = true, -- temporarily read-only
98
- }
99
- box.once("schema", function()
100
- box.schema.user.create('replicator', {password = 'password'})
101
- box.schema.user.grant('replicator', 'replication') -- grant replication role
102
- box.schema.space.create("test")
103
- box.space.test:create_index("primary")
104
- end)
105
-
106
- Here we make the following changes:
107
-
108
- * Add the URI of master #3 to the :ref: `replication <cfg_replication-replication >`
109
- parameter.
110
- * Temporarily specify :ref: `read_only=true <cfg_basic-read_only >` to disable
111
- data-change operations on the instance. After launch, master #3 will act as a
112
- replica until it retrieves all data from the other masters in the replica set.
113
-
114
- After we launch master #3, it gets connected to the other master
115
- instances and retrieves their write-ahead-log and snapshot files:
116
-
117
- .. code-block :: console
118
-
119
- $ # launching master #3
120
- $ tarantool master3.lua
121
- 2017-06-14 17:10:00.556 [47121] main/101/master3.lua C> version 1.7.4-52-g980d30092
122
- 2017-06-14 17:10:00.557 [47121] main/101/master3.lua C> log level 5
123
- 2017-06-14 17:10:00.557 [47121] main/101/master3.lua I> mapping 268435456 bytes for tuple arena...
124
- 2017-06-14 17:10:00.559 [47121] iproto/101/main I> binary: bound to [::]:3301
125
- 2017-06-14 17:10:00.559 [47121] main/104/applier/[email protected] I> remote master is 1.7.4 at 192.168.0.101:3301
126
- 2017-06-14 17:10:00.559 [47121] main/105/applier/[email protected] I> remote master is 1.7.4 at 192.168.0.102:3301
127
- 2017-06-14 17:10:00.559 [47121] main/106/applier/[email protected] I> remote master is 1.7.4 at 192.168.0.103:3301
128
- 2017-06-14 17:10:00.559 [47121] main/105/applier/[email protected] I> authenticated
129
- 2017-06-14 17:10:00.559 [47121] main/101/master3.lua I> bootstrapping replica from 192.168.0.102:3301
130
- 2017-06-14 17:10:00.562 [47121] main/105/applier/[email protected] I> initial data received
131
- 2017-06-14 17:10:00.562 [47121] main/105/applier/[email protected] I> final data received
132
- 2017-06-14 17:10:00.562 [47121] snapshot/101/main I> saving snapshot `/Users/e.shebunyaeva/work/tarantool-test-repl/master3_dir/00000000000000000009.snap.inprogress'
133
- 2017-06-14 17:10:00.562 [47121] snapshot/101/main I> done
134
- 2017-06-14 17:10:00.564 [47121] main/101/master3.lua I> vinyl checkpoint done
135
- 2017-06-14 17:10:00.564 [47121] main/101/master3.lua I> ready to accept requests
136
- 2017-06-14 17:10:00.565 [47121] main/101/master3.lua I> set 'read_only' configuration option to true
137
- 2017-06-14 17:10:00.565 [47121] main C> entering the event loop
138
- 2017-06-14 17:10:00.565 [47121] main/104/applier/[email protected] I> authenticated
139
-
140
- Next, we add the URI of master #3 to the ``replication `` parameter on the existing two
141
- masters. Replication-related parameters are dynamic, so we only need to make a
142
- ``box.cfg{} `` request on each of the running instances:
143
-
144
- .. code-block :: tarantoolsession
145
-
146
- # adding master #3 URI to replication sources
147
- tarantool> box.cfg{replication =
148
- > {'replicator:[email protected] :3301',
149
- > 'replicator:[email protected] :3301',
150
- > 'replicator:[email protected] :3301'}}
151
- ---
152
- ...
153
-
154
- When master #3 catches up with the other masters' state, we can disable
155
- read-only mode for this instance:
156
-
157
- .. code-block :: tarantoolsession
158
-
159
- # making master #3 a real master
160
- tarantool> box.cfg{read_only=false}
161
- ---
162
- ...
163
-
164
- We also recommend to specify master #3 URI in all instance files in order to
165
- keep all the files consistent with each other and with the current replication
166
- topology.
75
+ Master-master
76
+ -------------
77
+
78
+ 1. Update ``instances.yml ``:
79
+
80
+ .. literalinclude :: /code_snippets/snippets/replication/instances.enabled/master_master/instances.yml
81
+ :language: yaml
82
+ :dedent:
83
+
84
+ 2. Add ``instance003 ``:
85
+
86
+ .. literalinclude :: /code_snippets/snippets/replication/instances.enabled/master_master/config.yaml
87
+ :language: yaml
88
+ :start-at: groups:
89
+ :end-at: listen: 127.0.0.1:3303
90
+ :dedent:
91
+
92
+ 3. Start: ``tt start master_master:instance003 ``, ``tt status master_master ``.
93
+
94
+ 4. ``tt connect master_master:instance003 ``, ``box.info.ro ``.
0 commit comments