Skip to content

Commit 352dd4f

Browse files
committed
Supervised failover
1 parent fb2dd55 commit 352dd4f

File tree

11 files changed

+423
-158
lines changed

11 files changed

+423
-158
lines changed

doc/book/admin/start_stop_instance.rst

Lines changed: 1 addition & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ To get more context on how the application's environment might look, refer to :r
2121

2222

2323
.. _configuration_run_instance:
24+
.. _configuration_run_instance_tt:
2425

2526
Starting Tarantool instances
2627
----------------------------
2728

28-
.. _configuration_run_instance_tt:
29-
30-
Starting instances using the tt utility
31-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32-
3329
The :ref:`tt <tt-cli>` utility is the recommended way to start Tarantool instances.
3430

3531
.. code-block:: console
@@ -56,24 +52,6 @@ In the system launch mode, artifacts are created in these locations:
5652
* ``/var/run/tarantool/<instance_name>/``
5753

5854

59-
.. _configuration_run_instance_tarantool:
60-
61-
Starting an instance using the tarantool command
62-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63-
64-
The ``tarantool`` command provides additional :ref:`options <configuration_command_options>` that might be helpful for development purposes.
65-
Below is the syntax for starting a Tarantool instance configured in a file:
66-
67-
.. code-block:: console
68-
69-
$ tarantool [OPTION ...] --name INSTANCE_NAME --config CONFIG_FILE_PATH
70-
71-
The command below starts ``router-a-001`` configured in the ``config.yaml`` file:
72-
73-
.. code-block:: console
74-
75-
$ tarantool --name router-a-001 --config config.yaml
76-
7755

7856

7957
.. _admin-start_stop_instance_management:
@@ -252,138 +230,3 @@ by semicolons:
252230
253231
If an error happens during the execution of the preload script or module, Tarantool
254232
reports the problem and exits.
255-
256-
257-
258-
259-
.. _configuration_command_options:
260-
261-
tarantool command-line options
262-
------------------------------
263-
264-
Options that can be passed when :ref:`starting a Tarantool instance <configuration_run_instance_tarantool>`:
265-
266-
.. option:: -h, --help
267-
268-
Print an annotated list of all available options and exit.
269-
270-
.. option:: --help-env-list
271-
272-
**Since:** :doc:`3.0.0 </release/3.0.0>`.
273-
274-
Show a list of :ref:`environment variables <configuration_environment_variable>` that can be used to configure Tarantool.
275-
276-
.. _index-tarantool_version:
277-
278-
.. option:: -v, -V, --version
279-
280-
Print the product name and version.
281-
282-
**Example**
283-
284-
.. code-block:: console
285-
286-
$ tarantool --version
287-
Tarantool Enterprise 3.0.0-beta1-2-gcbb569b4c-r607-gc64
288-
Target: Linux-x86_64-RelWithDebInfo
289-
...
290-
291-
In this example:
292-
293-
* ``3.0.0`` is a Tarantool version.
294-
Tarantool follows semantic versioning, which is described in the :ref:`Tarantool release policy <release-policy>` section.
295-
296-
* ``Target`` is the platform Tarantool is built on.
297-
Platform-specific details may follow this line.
298-
299-
300-
.. option:: -c, --config PATH
301-
302-
**Since:** :doc:`3.0.0 </release/3.0.0>`.
303-
304-
Set a path to a :ref:`YAML configuration file <configuration_file>`.
305-
You can also configure this value using the ``TT_CONFIG`` environment variable.
306-
307-
See also: :ref:`Starting an instance using the tarantool command <configuration_run_instance_tarantool>`
308-
309-
.. option:: -n, --name INSTANCE
310-
311-
**Since:** :doc:`3.0.0 </release/3.0.0>`.
312-
313-
Set the name of an instance to run.
314-
You can also configure this value using the ``TT_INSTANCE_NAME`` environment variable.
315-
316-
See also: :ref:`Starting an instance using the tarantool command <configuration_run_instance_tarantool>`
317-
318-
319-
.. option:: -i
320-
321-
Enter an :ref:`interactive mode <interactive_console>`.
322-
323-
**Example**
324-
325-
.. code-block:: console
326-
327-
$ tarantool -i
328-
329-
330-
.. option:: -e EXPR
331-
332-
Execute the 'EXPR' string. See also: `lua man page <https://www.lua.org/manual/5.3/lua.html>`_.
333-
334-
**Example**
335-
336-
.. code-block:: console
337-
338-
$ tarantool -e 'print("Hello, world!")'
339-
Hello, world!
340-
341-
.. option:: -l NAME
342-
343-
Require the 'NAME' library. See also: `lua man page <https://www.lua.org/manual/5.3/lua.html>`_.
344-
345-
**Example**
346-
347-
.. code-block:: console
348-
349-
$ tarantool -l luatest.coverage script.lua
350-
351-
.. option:: -j cmd
352-
353-
Perform a LuaJIT control command. See also: `Command Line Options <https://luajit.org/running.html>`_.
354-
355-
**Example**
356-
357-
.. code-block:: console
358-
359-
$ tarantool -j off app.lua
360-
361-
.. option:: -b ...
362-
363-
Save or list bytecode. See also: `Command Line Options <https://luajit.org/running.html>`_.
364-
365-
**Example**
366-
367-
.. code-block:: console
368-
369-
$ tarantool -b test.lua test.out
370-
371-
.. option:: -d SCRIPT
372-
373-
Activate a debugging session for 'SCRIPT'. See also: `luadebug.lua <https://github.com/tarantool/tarantool/blob/master/third_party/lua/README-luadebug.md>`_.
374-
375-
**Example**
376-
377-
.. code-block:: console
378-
379-
$ tarantool -d app.lua
380-
381-
382-
.. option:: --
383-
384-
Stop handling options. See also: `lua man page <https://www.lua.org/manual/5.3/lua.html>`_.
385-
386-
387-
.. option:: -
388-
389-
Stop handling options and execute the standard input as a file. See also: `lua man page <https://www.lua.org/manual/5.3/lua.html>`_.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Master-replica: supervised failover (etcd)
2+
3+
A sample application demonstrating how to bootstrap a replica set that uses an external failover coordinator.
4+
The failover coordinator's state is stored in etcd along with a replica set configuration.
5+
6+
7+
## Running
8+
9+
1. Start etcd:
10+
11+
```console
12+
$ etcd
13+
```
14+
15+
2. Publish a replica set configuration to etcd by executing the `tt cluster publish` command in the [replication](../../../replication) directory:
16+
17+
```console
18+
$ tt cluster publish "http://localhost:2379/myapp" instances.enabled/supervised_failover_etcd/source.yaml
19+
```
20+
21+
3. To start the failover coordinator, execute the `tarantool` command with the `--failover` option:
22+
23+
```console
24+
$ tarantool --failover --config instances.enabled/supervised_failover_etcd/config.yaml
25+
```
26+
27+
4. Then, start the application as follows:
28+
29+
```console
30+
$ tt start supervised_failover_etcd
31+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /myapp
6+
http:
7+
request:
8+
timeout: 3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
credentials:
2+
users:
3+
replicator:
4+
password: 'topsecret'
5+
roles: [ replication ]
6+
privileges:
7+
- permissions: [ execute ]
8+
functions: [ 'failover.execute' ]
9+
10+
iproto:
11+
advertise:
12+
peer:
13+
login: replicator
14+
15+
replication:
16+
failover: supervised
17+
18+
failover:
19+
probe_interval: 5
20+
lease_interval: 15
21+
renew_interval: 5
22+
stateboard:
23+
keepalive_interval: 5
24+
renew_interval: 1
25+
26+
roles: [ 'supervised_instance' ]
27+
28+
groups:
29+
group001:
30+
replicasets:
31+
replicaset001:
32+
instances:
33+
instance001:
34+
iproto:
35+
listen:
36+
- uri: '127.0.0.1:3301'
37+
instance002:
38+
iproto:
39+
listen:
40+
- uri: '127.0.0.1:3302'
41+
instance003:
42+
iproto:
43+
listen:
44+
- uri: '127.0.0.1:3303'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
return {
2+
validate = function()
3+
end,
4+
apply = function()
5+
if box.info.ro then
6+
return
7+
end
8+
local func_name = 'failover.execute'
9+
local opts = { if_not_exists = true }
10+
box.schema.func.create(func_name, opts)
11+
end,
12+
stop = function()
13+
if box.info.ro then
14+
return
15+
end
16+
local func_name = 'failover.execute'
17+
if not box.schema.func.exists(func_name) then
18+
return
19+
end
20+
box.schema.func.drop(func_name)
21+
end,
22+
}

doc/concepts/replication/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This section includes the following topics:
1919
repl_architecture
2020
repl_sync
2121
repl_leader_elect
22+
supervised_failover
2223

2324
For practical guides to replication, see :ref:`Replication tutorials <how-to-replication>`.
2425
You can learn about bootstrapping a replica set, adding instances to the replica set, or removing them.

0 commit comments

Comments
 (0)