Skip to content

Commit c3e8597

Browse files
committed
3.0 config - update per review
1 parent 99fa56a commit c3e8597

File tree

5 files changed

+163
-95
lines changed

5 files changed

+163
-95
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Configuration
2+
3+
A sample application demonstrating various features related to Tarantool [configuration](https://www.tarantool.io/en/doc/latest/concepts/configuration/).
4+
5+
## Running
6+
7+
To run applications placed in [instances.enabled](instances.enabled), go to the `config` directory in the terminal and execute the `tt start` command, for example:
8+
9+
```console
10+
$ tt start application
11+
```

doc/concepts/configuration.rst

Lines changed: 91 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ There are two approaches to configuring Tarantool:
88
* *Since version 3.0*: In a YAML file.
99

1010
In a YAML file, you can provide the full cluster topology and specify all configuration options.
11-
You can also use :ref:`etcd <configuration_centralized>` to store configuration data in one reliable place.
11+
You can also use :ref:`etcd <configuration_etcd_overview>` to store configuration data in one reliable place.
1212

1313
* *In version 2.11 and earlier*: :ref:`In code <configuration_code>` using the ``box.cfg`` API.
1414

@@ -73,7 +73,7 @@ Most of the configuration options can be applied to a specific instance, replica
7373

7474
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/instance_scope/config.yaml
7575
:language: yaml
76-
:emphasize-lines: 6-8
76+
:emphasize-lines: 7-8
7777
:dedent:
7878

7979
- *Replica set*
@@ -82,7 +82,7 @@ Most of the configuration options can be applied to a specific instance, replica
8282

8383
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/replicaset_scope/config.yaml
8484
:language: yaml
85-
:emphasize-lines: 4-6
85+
:emphasize-lines: 5-6
8686
:dedent:
8787

8888
- *Group*
@@ -91,7 +91,7 @@ Most of the configuration options can be applied to a specific instance, replica
9191

9292
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/group_scope/config.yaml
9393
:language: yaml
94-
:emphasize-lines: 2-4
94+
:emphasize-lines: 3-4
9595
:dedent:
9696

9797
- *Global*
@@ -111,38 +111,38 @@ Most of the configuration options can be applied to a specific instance, replica
111111

112112
.. _configuration_replica_set_scopes:
113113

114-
Replica set configuration and configuration scopes
115-
**************************************************
114+
Configuration scopes: Replica set example
115+
*****************************************
116116

117-
This section shows how to configure a :ref:`replica set <replication>` with a manual failover
118-
and describes how specific configuration options work in different configuration scopes.
117+
The example below shows how specific configuration options work in different configuration scopes for a replica set with a manual failover.
118+
You can learn more about configuring replication from :ref:`Replication tutorials <how-to-replication>`.
119119

120120
.. literalinclude:: /code_snippets/snippets/replication/instances.enabled/manual_leader/config.yaml
121121
:language: yaml
122+
:emphasize-lines: 1-8,10-12,14-15,21,24-25,27-28,30-31
122123
:end-before: Load sample data
123124
:dedent:
124125

125126
- ``credentials`` (*global*)
126127

127-
Options in this section grant the specified privileges to the *replicator* user used for replication and
128-
the *client* user that can perform any action.
128+
Options in this section grant the specified roles to the *replicator* and *client* users.
129129
These options are applied globally to all instances.
130130

131131
- ``iproto`` (*global*, *instance*)
132132

133133
The ``iproto`` section is specified on both global and instance levels.
134-
The ``iproto.advertise.peer`` option specifies a user name and a host used by replicas to connect to each other.
135-
In this example, a host is not specified and taken from ``iproto.listen`` set on the instance level.
134+
The ``iproto.advertise.peer`` option specifies a URI used by an instance to connect to another instance as a replica.
135+
In the example above, the URI includes a user name only.
136+
A host value is taken from ``iproto.listen`` that is set on the instance level.
136137

137138
- ``replication``: (*global*)
138139

139140
The ``replication.failover`` global option sets a manual failover for all replica sets.
140141

141142
- ``leader``: (*replica set*)
142143

143-
The ``<replicaset-name>.leader`` option sets a :ref:`master <replication-roles>` instance for the specified replica set.
144+
The ``<replicaset-name>.leader`` option sets a :ref:`master <replication-roles>` instance for *replicaset001*.
144145

145-
To learn more about configuring replication and sharding, see :ref:`Replication tutorials <how-to-replication>` and :ref:`Quick start with sharding <vshard-quick-start>` sections.
146146

147147

148148
.. _configuration_application:
@@ -166,7 +166,7 @@ use the ``config:get()`` function provided by the :ref:`config <config-module>`
166166
:language: lua
167167
:dedent:
168168

169-
As a result of :ref:`running <configuration_run_instance>` the *instance001*, a log should contain the following line:
169+
As a result of :ref:`starting <configuration_run_instance>` the *instance001*, a log should contain the following line:
170170

171171
.. code-block:: console
172172
@@ -191,19 +191,25 @@ Learn more about using Tarantool as the application server from :ref:`Developing
191191

192192

193193

194-
.. _configuration_templating:
194+
.. _configuration_predefined_variables:
195195

196-
Templating
197-
**********
196+
Predefined variables
197+
********************
198+
199+
In a configuration file, you can use the following predefined variables that are replaced with actual values at runtime:
198200

199-
In a configuration file, you can use predefined variables that are replaced with actual values at runtime.
201+
- ``instance_name``
202+
- ``replicaset_name``
203+
- ``group_name``
204+
205+
To reference such variables in a configuration file, use double curly braces.
200206
In the example below, ``{{ instance_name }}`` is replaced with *instance001*.
201207

202208
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/templating/config.yaml
203209
:language: yaml
204210
:dedent:
205211

206-
As a result, the paths to snapshots and write-ahead logs differ for different instances.
212+
As a result, the :ref:`paths to snapshots and write-ahead logs <configuration_options_directories>` differ for different instances.
207213

208214

209215

@@ -228,48 +234,76 @@ To see all the supported environment variables, execute the ``tarantool`` comman
228234
229235
$ tarantool --help-env-list
230236
231-
Below are a few examples that show how to set environment variables of different types:
237+
Below are a few examples that show how to set environment variables of different types, like *string*, *number*, *array*, or *map*:
232238

233-
* In the example below, ``TT_IPROTO_LISTEN`` is used to specify a :ref:`listening host and port <configuration_options_connection>` values:
239+
* (*String*) In the example below, ``TT_IPROTO_LISTEN`` is used to specify a :ref:`listening host and port <configuration_options_connection>` values:
234240

235241
.. code-block:: console
236242
237243
$ export TT_IPROTO_LISTEN='127.0.0.1:3311'
238244
239-
* To specify several listening addresses, separate them by a comma without space:
245+
To specify several listening addresses, separate them by a comma without space:
240246

241247
.. code-block:: console
242248
243249
$ export TT_IPROTO_LISTEN='127.0.0.1:3311,127.0.0.1:3312'
244250
245-
* To assign map values to environment variables, use JSON objects.
246-
In the example below, ``TT_APP_CFG`` is used to specify the value of a custom configuration property for a :ref:`loaded application <configuration_application>:
251+
* (*Number*) In this example, ``TT_LOG_LEVEL`` is used to set a logging level to 3 (``CRITICAL``):
252+
253+
.. code-block:: console
254+
255+
$ export TT_LOG_LEVEL=3
256+
257+
* (*Array*) The examples below show how to set the ``TT_SHARDING_ROLES`` variable that accepts an array value.
258+
Arrays can be passed in a *simple* ...
259+
260+
.. code-block:: console
261+
262+
$ export TT_SHARDING_ROLES=router,storage
263+
264+
or *JSON* format:
265+
266+
.. code-block:: console
267+
268+
$ export TT_SHARDING_ROLES='["router", "storage"]'
269+
270+
The *simple* format is applicable only to arrays containing scalar values.
271+
272+
* (*Map*) To assign map values to environment variables, you can also use *simple* or *JSON* formats.
273+
In the example below, ``TT_LOG_MODULES`` sets different logging levels for different modules using a *simple* format:
274+
275+
.. code-block:: console
276+
277+
$ export TT_LOG_MODULES=module1=info,module2=error
278+
279+
In the next example, ``TT_APP_CFG`` is used to specify the value of a custom configuration property for a :ref:`loaded application <configuration_application>` using a *JSON* format:
247280

248281
.. code-block:: console
249282
250283
$ export TT_APP_CFG='{"greeting":"Hi"}'
251284
285+
The *simple* format is applicable only to maps containing scalar values.
252286

253-
.. NOTE::
254287

255-
The ``TT_INSTANCE_NAME`` and ``TT_CONFIG`` environment variables can be used to :ref:`run <configuration_run_instance>` the specified Tarantool instance with configuration from the given file.
288+
.. NOTE::
256289

290+
There are also special ``TT_INSTANCE_NAME`` and ``TT_CONFIG`` environment variables that can be used to :ref:`start <configuration_run_instance_tarantool>` the specified Tarantool instance with configuration from the given file.
257291

258292

259293

260294

261295

262-
.. _configuration_centralized:
263296

264-
Centralized configuration
265-
~~~~~~~~~~~~~~~~~~~~~~~~~
297+
.. _configuration_etcd_overview:
266298

267-
.. admonition:: Enterprise Edition
268-
:class: fact
299+
Configuration in etcd
300+
~~~~~~~~~~~~~~~~~~~~~
269301

270-
Centralized configuration is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
302+
.. include:: /concepts/configuration/configuration_etcd.rst
303+
:start-after: ee_note_etcd_start
304+
:end-before: ee_note_etcd_end
271305

272-
Tarantool enables you to store configuration data in one reliable place using etcd.
306+
Tarantool enables you to store configuration data in one reliable place using `etcd <https://etcd.io/>`_.
273307
To achieve this, you need to:
274308

275309
1. Provide a local YAML configuration with an etcd endpoint address and key prefix in the ``config`` section:
@@ -288,14 +322,14 @@ Learn more from the following guide: :ref:`Storing configuration in etcd <config
288322
Configuration precedence
289323
~~~~~~~~~~~~~~~~~~~~~~~~
290324

291-
Tarantool configuration options are applied in the following order:
325+
Tarantool configuration options are applied from multiple sources with the following precedence, from highest to lowest:
292326

293-
- `TT_*_DEFAULT` :ref:`environment variables <configuration_environment_variable>`.
294-
- :ref:`Centralized configuration <configuration_centralized>` stored in etcd.
295-
- Configuration from a :ref:`local YAML file <configuration_file>`.
296327
- `TT_*` :ref:`environment variables <configuration_environment_variable>`.
328+
- Configuration from a :ref:`local YAML file <configuration_file>`.
329+
- :ref:`Centralized configuration <configuration_etcd_overview>` stored in etcd.
330+
- `TT_*_DEFAULT` :ref:`environment variables <configuration_environment_variable>`.
297331

298-
This means that `TT_*` environment variables have a higher priority than other configuration ways.
332+
If the same option is defined in two or more locations, the option with the highest precedence is applied.
299333

300334

301335

@@ -352,7 +386,7 @@ Below are a few examples on how to do this:
352386
.. code-block:: yaml
353387
354388
iproto:
355-
listen: "unix/:./{{ instance_name }}.iproto"
389+
listen: "unix/:./var/run/{{ instance_name }}/tarantool.iproto"
356390
357391
358392
.. _configuration_options_access_control:
@@ -379,7 +413,7 @@ To learn more, see the :ref:`Access control <authentication>` section.
379413
Memory
380414
~~~~~~
381415

382-
The ``memtx.memory`` option specifies how much memory Tarantool allocates to actually store data.
416+
The ``memtx.memory`` option specifies how much :ref:`memory <engines-memtx>` Tarantool allocates to actually store data.
383417

384418
.. code-block:: yaml
385419
@@ -395,15 +429,17 @@ Snapshots and write-ahead logs
395429
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396430

397431
The ``snapshot.dir`` and ``wal.dir`` options can be used to configure directories for storing snapshots and write-ahead logs.
432+
For example, you can place snapshots and write-ahead logs on different hard drives for better reliability.
398433

399434
.. code-block:: yaml
400435
401436
instance001:
402437
snapshot:
403-
dir: 'var/snapshots'
438+
dir: '/media/drive1/snapshots'
404439
wal:
405-
dir: 'var/wals'
440+
dir: '/media/drive2/wals'
406441
442+
To learn more about the persistence mechanism in Tarantool, see the :ref:`Persistence <concepts-data_model-persistence>` section.
407443

408444

409445
.. _configuration_run_instance:
@@ -423,11 +459,12 @@ The example below shows how a :ref:`layout <admin-start_stop_instance-multi-inst
423459

424460
.. code-block:: none
425461
426-
instances.enabled
427-
└── app
428-
├── config.yaml
429-
├── myapp.lua
430-
└── instances.yml
462+
├── tt.yaml
463+
└── instances.enabled
464+
└── app
465+
├── config.yaml
466+
├── myapp.lua
467+
└── instances.yml
431468
432469
* ``config.yaml`` is a :ref:`configuration file <configuration_file>`.
433470
* ``myapp.lua`` is a Lua script containing an :ref:`application to load <configuration_application>`.
@@ -447,6 +484,7 @@ To start all instances, use the ``tt start app`` command:
447484
• Starting an instance [app:instance002]...
448485
• Starting an instance [app:instance003]...
449486
487+
Then, you can connect to Tarantool instances by its names using the ``tt connect`` command.
450488
You can learn more from the :ref:`Starting and stopping instances <admin-start_stop_instance>` section.
451489

452490

@@ -461,7 +499,7 @@ Below is the syntax for starting a Tarantool instance configured in a file:
461499

462500
.. code-block:: console
463501
464-
$ tarantool --name INSTANCE_NAME --config CONFIG_FILE_PATH [OPTION ...]
502+
$ tarantool [OPTION ...] --name INSTANCE_NAME --config CONFIG_FILE_PATH
465503
466504
The command below starts ``instance001`` configured in the ``config.yaml`` file:
467505

@@ -475,15 +513,15 @@ The command below starts ``instance001`` configured in the ``config.yaml`` file:
475513
Command-line options
476514
********************
477515

478-
Options that can be passed when :ref:`running a Tarantool instance <configuration_run_instance_tarantool>`:
516+
Options that can be passed when :ref:`starting a Tarantool instance <configuration_run_instance_tarantool>`:
479517

480518
.. option:: -h, --help
481519

482520
Print an annotated list of all available options and exit.
483521

484522
.. option:: --help-env-list
485523

486-
**Since:** :tarantool-release:`3.0.0`
524+
**Since:** :doc:`3.0.0 </release/3.0.0>`.
487525

488526
Show a list of :ref:`environment variables <configuration_environment_variable>` that can be used to configure Tarantool.
489527

@@ -513,7 +551,7 @@ Options that can be passed when :ref:`running a Tarantool instance <configuratio
513551

514552
.. option:: -c, --config PATH
515553

516-
**Since:** :tarantool-release:`3.0.0`
554+
**Since:** :doc:`3.0.0 </release/3.0.0>`.
517555

518556
Set a path to a :ref:`YAML configuration file <configuration_file>`.
519557
You can also configure this value using the ``TT_CONFIG`` environment variable.
@@ -522,7 +560,7 @@ Options that can be passed when :ref:`running a Tarantool instance <configuratio
522560

523561
.. option:: -n, --name INSTANCE
524562

525-
**Since:** :tarantool-release:`3.0.0`
563+
**Since:** :doc:`3.0.0 </release/3.0.0>`.
526564

527565
Set the name of an instance to run.
528566
You can also configure this value using the ``TT_INSTANCE_NAME`` environment variable.

0 commit comments

Comments
 (0)