Skip to content

Commit 5b0b30d

Browse files
p7novandreyaksenov
andauthored
TCM data storages: etcd and Tarantool (#4123)
Resolves #4123 Co-authored-by: Andrey Aksenov <38073144+andreyaksenov@users.noreply.github.com>
1 parent 24a959d commit 5b0b30d

File tree

4 files changed

+532
-145
lines changed

4 files changed

+532
-145
lines changed

doc/reference/tooling/tcm/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ to read data. LDAP authorization is supported as well.
4242
tcm_access_control
4343
tcm_audit_log
4444
tcm_configuration
45+
tcm_backend_store
4546
tcm_configuration_reference
Lines changed: 386 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,386 @@
1+
.. _tcm_backend_store:
2+
3+
Backend store
4+
=============
5+
6+
.. include:: index.rst
7+
:start-after: ee_note_tcm_start
8+
:end-before: ee_note_tcm_end
9+
10+
|tcm_full_name| uses an underlying data store (*backend store*) for its entities:
11+
users, roles, cluster connections, settings, and other objects that you manipulate in |tcm|.
12+
The backend store can be either an etcd or a Tarantool cluster.
13+
14+
For better reliability and scalability, the backend store works independently from |tcm|.
15+
For example, it can be the same ectd or Tarantool cluster that you use as a :ref:`centralized configuration storage <configuration_etcd>`.
16+
This makes |tcm| stateless: all objects created or modified in its web UI are saved
17+
to the backend store, and nothing is stored inside the |tcm| instances themselves.
18+
Any number of instances can duplicate each other when connected to the same backend store.
19+
If you stop all instances, the store still contains their objects. You can continue
20+
working with them right after starting a new instance.
21+
22+
In addition to using an external backend store, you can run |tcm| with an embedded
23+
etcd or Tarantool instance to use as the backend store.
24+
25+
On this page, you will learn to connect |tcm| to backend stores of both types,
26+
or start |tcm| with an embedded backend store.
27+
28+
.. _tcm_backend_store_set_up:
29+
30+
Setting up a backend store
31+
--------------------------
32+
33+
The |tcm| backend store requires the same configuration as
34+
:ref:`Tarantool centralized configuration storage <configuration_etcd>`.
35+
Follow the instructions in :ref:`centralized_configuration_storage_set_up` to
36+
set up a backend store.
37+
38+
.. note::
39+
40+
If you already have the centralized configuration store for your Tarantool clusters,
41+
you can use it as a |tcm| backend store as well.
42+
43+
.. _tcm_backend_store_connect:
44+
45+
Configuring backend store connection
46+
------------------------------------
47+
48+
The |tcm|'s connection to its backend store is configured using the :ref:`storage.* <tcm_configuration_reference_storage>`
49+
configuration options. The :ref:`storage.provider <tcm_configuration_reference_storage_provider>`
50+
option selects the store type. It can be either ``etcd`` or ``tarantool``.
51+
52+
.. _tcm_backend_store_connect_etcd:
53+
54+
External etcd store
55+
~~~~~~~~~~~~~~~~~~~
56+
57+
To use an etcd cluster as a |tcm| backend store, set the ``storage.provider`` option
58+
to ``etcd`` and specify connection parameters in ``storage.etcd.*`` options.
59+
A minimal etcd configuration includes the storage endpoints:
60+
61+
.. code-block:: yaml
62+
63+
storage:
64+
provider: etcd
65+
etcd:
66+
endpoints:
67+
- http://127.0.0.1:2379
68+
69+
If authentication is enabled in etcd, specify ``storage.etcd.username`` and ``storage.etcd.password``:
70+
71+
.. code-block:: yaml
72+
73+
storage:
74+
provider: etcd
75+
etcd:
76+
endpoints:
77+
- http://127.0.0.1:2379
78+
username: etcduser
79+
password: secret
80+
81+
The |tcm| data is stored in etcd under the prefix specified in ``storage.etcd.prefix``.
82+
By default, the prefix is ``/tcm``. If you want to change it or store data of
83+
different |tcm| instances separately in one etcd cluster, set the prefix explicitly:
84+
85+
.. code-block:: yaml
86+
87+
storage:
88+
provider: etcd
89+
etcd:
90+
endpoints:
91+
- http://127.0.0.1:2379
92+
prefix: /tcm2
93+
94+
95+
Other ``storage.etcd.*`` options configure various aspects of the etcd store connection,
96+
such as network timeouts and limits or TLS parameters.
97+
For the full list of the etcd |tcm| backend store options, see the
98+
:ref:`TCM configuration reference <tcm_configuration_reference_storage>`.
99+
100+
.. _tcm_backend_store_connect_tarantool:
101+
102+
External Tarantool-based store
103+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104+
105+
To use a Tarantool cluster as a |tcm| backend store, set the ``storage.provider`` option
106+
to ``tarantool`` and specify connection parameters in ``storage.tarantool.*`` options.
107+
A minimal configuration includes the one or more addresses of
108+
the backend store instances:
109+
110+
.. code-block:: yaml
111+
112+
storage:
113+
provider: tarantool
114+
tarantool:
115+
addr: http://127.0.0.1:3301
116+
117+
Or:
118+
119+
.. code-block:: yaml
120+
121+
storage:
122+
provider: tarantool
123+
tarantool:
124+
addrs:
125+
- http://127.0.0.1:3301
126+
- http://127.0.0.1:3302
127+
- http://127.0.0.1:3303
128+
129+
If authentication is enabled in the backend store, specify ``storage.tarantool.username``
130+
and ``storage.tarantool.password``:
131+
132+
.. code-block:: yaml
133+
134+
storage:
135+
provider: tarantool
136+
tarantool:
137+
addr: http://127.0.0.1:3301
138+
username: tarantooluser
139+
password: secret
140+
141+
The |tcm| data is stored in the Tarantool-based backend store under the prefix
142+
specified in ``storage.tarantool.prefix``.
143+
By default, the prefix is ``/tcm``. If you want to change it or store data of
144+
different |tcm| instances separately in one Tarantool cluster, set the prefix explicitly:
145+
146+
.. code-block:: yaml
147+
148+
storage:
149+
provider: tarantool
150+
tarantool:
151+
addr: http://127.0.0.1:3301
152+
username: tarantooluser
153+
password: secret
154+
prefix: /tcm2
155+
156+
157+
Other ``storage.tarantool.*`` options configure various aspects of |tcm| connection
158+
to the Tarantool-based backend store, such as network timeouts and limits or TLS parameters.
159+
For the full list of the Tarantool-based |tcm| backend store options, see the
160+
:ref:`TCM configuration reference <tcm_configuration_reference_storage>`.
161+
162+
.. _tcm_backend_store_embed:
163+
164+
Embedded backend store
165+
----------------------
166+
167+
For development purposes, you can start |tcm| with an embedded backend store.
168+
This is useful for local runs when you don't have or don't need an external backend store.
169+
170+
An embedded |tcm| backend store is a single instance of etcd or Tarantool that
171+
is started automatically on the same host during the |tcm| startup. It runs
172+
in the background until |tcm| is stopped. The embedded backend store is persistent:
173+
if you start |tcm| again with the same backend store configuration, it restores
174+
the |tcm| data from the previous runs.
175+
176+
.. note::
177+
178+
To start a clean instance of |tcm|, remove the working directory of the
179+
embedded backend store specified in the ``storage.etcd.embed.workdir`` or
180+
``storage.tarantool.embed.workdir`` option.
181+
182+
The embedded backend store parameters are configured using the ``storage.etcd.embed.*`` options
183+
for etcd or ``storage.tarantool.embed.*`` options for a Tarantool-based store.
184+
185+
To start |tcm| with an embedded etcd with default settings, set ``storage.etcd.embed.enabled`` to ``true``
186+
and leave other ``storage.*`` options default:
187+
188+
.. code-block:: yaml
189+
190+
storage.etcd.embed.enabled: true
191+
192+
You can use the following call to get |tcm| running with embedded etcd without
193+
a configuration file:
194+
195+
.. code-block:: console
196+
197+
$ tcm --storage.etcd.embed.enabled
198+
199+
To start |tcm| with an embedded Tarantool storage with default settings:
200+
201+
* set ``storage.provider`` to ``tarantool``
202+
* set ``storage.tarantool.embed.enabled`` to ``true``
203+
204+
.. code-block:: yaml
205+
206+
storage:
207+
provider: tarantool
208+
tarantool.embed.enabled: true
209+
210+
With command-line arguments:
211+
212+
.. code-block:: console
213+
214+
$ tcm --storage.provider=tarantool --storage.tarantool.embed.enabled
215+
216+
You can tune the embedded backend store, for example, enable and configure TLS on it
217+
or change its working directories or startup arguments. To set specific parameters,
218+
specify the corresponding ``storage.etcd.embed.*`` or ``storage.tarantool.embed.*``
219+
options. For the full list of configuration options of embedded backend stores, see the
220+
:ref:`TCM configuration reference <tcm_configuration_reference_storage>`.
221+
222+
.. _tcm_backend_store_embed_cluster:
223+
224+
Setting up a cluster of embedded backend stores
225+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226+
227+
To simulate the production environment, you can form a distributed multi-instance cluster
228+
from embedded stores of multiple |tcm| instances. To do this, configure each |tcm|
229+
instance's embedded store to join each other.
230+
231+
For etcd, provide the embedded store clustering parameters ``storage.etcd.embed.*``
232+
and specify the endpoints in ``storage.etcd.endpoints``. The options that configure
233+
embedded etcd mostly match the etcd configuration options. For more information
234+
about these options, see the `etcd documentation <https://etcd.io/docs/latest/op-guide/configuration/>`__.
235+
236+
Below are example configurations of three |tcm| instances that start with embedded etcd instances
237+
and form an etcd cluster from them:
238+
239+
* First instance:
240+
241+
.. code-block:: yaml
242+
243+
http.port: 8080
244+
storage:
245+
provider: etcd
246+
etcd:
247+
endpoints:
248+
- http://127.0.0.1:2379
249+
- http://127.0.0.1:22379
250+
- http://127.0.0.1:32379
251+
embed:
252+
enabled: true
253+
name: infra1
254+
endpoints: http://127.0.0.1:2379
255+
advertises: http://127.0.0.1:2379
256+
initial-cluster-state: new
257+
initial-cluster: infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380
258+
initial-cluster-token: etcd-cluster-1
259+
peer-endpoints: http://127.0.0.1:12380
260+
peer-advertises: http://127.0.0.1:12380
261+
workdir: node1.etcd
262+
263+
* Second instance:
264+
265+
.. code-block:: yaml
266+
267+
http.port: 8081
268+
storage:
269+
provider: etcd
270+
etcd:
271+
endpoints:
272+
- http://127.0.0.1:2379
273+
- http://127.0.0.1:22379
274+
- http://127.0.0.1:32379
275+
embed:
276+
enabled: true
277+
name: infra2
278+
endpoints: http://127.0.0.1:22379
279+
advertises: http://127.0.0.1:22379
280+
initial-cluster-state: new
281+
initial-cluster: infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380
282+
initial-cluster-token: etcd-cluster-1
283+
peer-endpoints: http://127.0.0.1:22380
284+
peer-advertises: http://127.0.0.1:22380
285+
workdir: node2.etcd
286+
287+
* Third instance:
288+
289+
.. code-block:: yaml
290+
291+
http.port: 8082
292+
storage:
293+
provider: etcd
294+
etcd:
295+
endpoints:
296+
- http://127.0.0.1:2379
297+
- http://127.0.0.1:22379
298+
- http://127.0.0.1:32379
299+
embed:
300+
enabled: true
301+
name: infra3
302+
endpoints: http://127.0.0.1:32379
303+
advertises: http://127.0.0.1:32379
304+
initial-cluster-state: new
305+
initial-cluster: infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380
306+
initial-cluster-token: etcd-cluster-1
307+
peer-endpoints: http://127.0.0.1:32380
308+
peer-advertises: http://127.0.0.1:32380
309+
workdir: node3.etcd
310+
311+
312+
To set up a cluster from embedded Tarantool-based backend stores:
313+
314+
1. Specify the Tarantool cluster configuration in ``storage.tarantool.embed.config``
315+
(as a plain text) or ``storage.tarantool.embed.config-file`` (as a YAML file).
316+
2. Assign an instance name from this configuration to each instance using ``storage.tarantool.embed.args``
317+
to each embedded store.
318+
319+
Below are example configurations of three |tcm| instances that start with embedded
320+
Tarantool-based backend stores and form a cluster from them:
321+
322+
* First instance:
323+
324+
.. code-block:: yaml
325+
326+
http.port: 8080
327+
storage:
328+
provider: tarantool
329+
tarantool:
330+
addrs:
331+
- http://127.0.0.1:3301
332+
- http://127.0.0.1:3302
333+
- http://127.0.0.1:3303
334+
embed:
335+
enabled: true
336+
config-filename: config.yml
337+
workdir: node1.tarantool
338+
args:
339+
- --name
340+
- instance-001
341+
- --config
342+
- config.yml
343+
344+
* Second instance:
345+
346+
.. code-block:: yaml
347+
348+
http.port: 8081
349+
storage:
350+
provider: tarantool
351+
tarantool:
352+
addrs:
353+
- http://127.0.0.1:3301
354+
- http://127.0.0.1:3302
355+
- http://127.0.0.1:3303
356+
embed:
357+
enabled: true
358+
config-filename: config.yml
359+
workdir: node2.tarantool
360+
args:
361+
- --name
362+
- instance-002
363+
- --config
364+
- config.yml
365+
366+
* Third instance:
367+
368+
.. code-block:: yaml
369+
370+
http.port: 8082
371+
storage:
372+
provider: tarantool
373+
tarantool:
374+
addrs:
375+
- http://127.0.0.1:3301
376+
- http://127.0.0.1:3302
377+
- http://127.0.0.1:3303
378+
embed:
379+
enabled: true
380+
config-filename: config.yml
381+
workdir: node3.tarantool
382+
args:
383+
- --name
384+
- instance-003
385+
- --config
386+
- config.yml

0 commit comments

Comments
 (0)