Skip to content

TCM get started: merge samples #4030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Getting started with Tarantool Cluster Manager

A sample application created in the [Getting started with Tarantool Cluster Manager](https://www.tarantool.io/en/doc/latest/how-to/getting_started_tcm/) tutorial.

## Running

Before starting instances, set up a Tarantool EE cluster as described in the tutorial.
Then, start all instances by executing the following command in the [config](../../../config) directory:

```console
$ tt start tcm_get_started
```

>
> To publish a cluster's configuration to etcd using tt, execute `tt cluster publish`:
>
> ```shell
> tt cluster publish "http://localhost:2379/default" instances.enabled/tcm_get_started/cluster.yaml
> ```
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ groups:
listen:
- uri: '127.0.0.1:3303'
advertise:
client: '127.0.0.1:3303'
client: '127.0.0.1:3303'
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ config:
etcd:
endpoints:
- http://localhost:2379
prefix: /default
prefix: /default
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
instance-001:
instance-002:
instance-003:
instance-003:
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ end

function select_data()
box.space.bands:select { 3 }
end
end

This file was deleted.

23 changes: 14 additions & 9 deletions doc/how-to/getting_started_tcm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Getting started with Tarantool Cluster Manager

This tutorial uses `Tarantool Enterprise Edition <https://www.tarantool.io/compare/>`_.

**Example on GitHub**: `tcm_get_started <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started>`_

In this tutorial, you get :ref:`tcm` up and running on your local system, deploy
a local Tarantool EE cluster, and learn to manage the cluster from the |tcm| web UI.

Expand Down Expand Up @@ -179,7 +181,7 @@ To write the cluster configuration and upload it to the etcd storage:
#. Click **+** and provide an arbitrary name for the configuration file, for example, ``all``.
#. Paste the following :ref:`YAML configuration <configuration_overview>` into the editor:

.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started_config/config.yaml
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started/cluster.yaml
:language: yaml
:dedent:

Expand Down Expand Up @@ -229,14 +231,14 @@ To deploy a local cluster based on the configuration from etcd:

* ``instances.yml`` specifies instances to run in the current environment. In this example, there are three instances:

.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/instances.yml
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started/instances.yml
:language: yaml
:dedent:

* ``config.yaml`` instructs ``tt`` to load the cluster configuration from etcd.
The specified etcd location matches the configuration storage of the **Default cluster** in TCM:

.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/config.yaml
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started/config.yaml
:language: yaml
:dedent:

Expand Down Expand Up @@ -309,9 +311,10 @@ Creating a space
Go to the terminal of ``instance-001`` (the leader instance) and run the following code to
create a formatted space with a primary index in the cluster:

.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/myapp.lua
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started/myapp.lua
:language: lua
:lines: 2-8
:start-at: box.schema.space.create
:end-at: box.space.bands:create_index
:dedent:

.. _getting_started_tcm_manage_write:
Expand All @@ -323,9 +326,10 @@ Since ``instance-001`` is a read-write instance (its ``box.info.ro`` is ``false`
the write requests must be executed on it. Run the following code in the ``instance-001``
terminal to write tuples in the space:

.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/myapp.lua
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started/myapp.lua
:language: lua
:lines: 13-15
:start-at: 'Roxette'
:end-at: 'Ace of Base'
:dedent:

.. _getting_started_tcm_manage_read:
Expand All @@ -335,9 +339,10 @@ Reading data

Check the space's tuples by running a read request on ``instance-001``:

.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/myapp.lua
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/tcm_get_started/myapp.lua
:language: lua
:lines: 19
:start-at: box.space.bands:select
:end-at: box.space.bands:select
:dedent:

This is how it looks in |tcm|:
Expand Down