From 04b231956035045be0b19a45660c19e80a811cb2 Mon Sep 17 00:00:00 2001 From: Andrey Aksenov <38073144+andreyaksenov@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:54:31 +0300 Subject: [PATCH] TCM get started: merge samples (#4030) --- .../tcm_get_started/README.md | 19 +++++++++++++++ .../cluster.yaml} | 2 +- .../config.yaml | 2 +- .../instances.yml | 2 +- .../myapp.lua | 2 +- .../tcm_get_started_tt/instances.yml | 3 --- doc/how-to/getting_started_tcm.rst | 23 +++++++++++-------- 7 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/README.md rename doc/code_snippets/snippets/config/instances.enabled/{tcm_get_started_config/config.yaml => tcm_get_started/cluster.yaml} (94%) rename doc/code_snippets/snippets/config/instances.enabled/{tcm_get_started_tt => tcm_get_started}/config.yaml (73%) rename doc/code_snippets/snippets/config/instances.enabled/{tcm_get_started_config => tcm_get_started}/instances.yml (66%) rename doc/code_snippets/snippets/config/instances.enabled/{tcm_get_started_tt => tcm_get_started}/myapp.lua (99%) delete mode 100644 doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/instances.yml diff --git a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/README.md b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/README.md new file mode 100644 index 0000000000..c7f3f75ae7 --- /dev/null +++ b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/README.md @@ -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 +> ``` diff --git a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_config/config.yaml b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/cluster.yaml similarity index 94% rename from doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_config/config.yaml rename to doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/cluster.yaml index 7ba68f27f1..4ba95bf0a1 100644 --- a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_config/config.yaml +++ b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/cluster.yaml @@ -27,4 +27,4 @@ groups: listen: - uri: '127.0.0.1:3303' advertise: - client: '127.0.0.1:3303' \ No newline at end of file + client: '127.0.0.1:3303' diff --git a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/config.yaml b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/config.yaml similarity index 73% rename from doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/config.yaml rename to doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/config.yaml index 52616f5e84..3071113699 100644 --- a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/config.yaml +++ b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/config.yaml @@ -2,4 +2,4 @@ config: etcd: endpoints: - http://localhost:2379 - prefix: /default \ No newline at end of file + prefix: /default diff --git a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_config/instances.yml b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/instances.yml similarity index 66% rename from doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_config/instances.yml rename to doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/instances.yml index cb21a1f662..c9e5954a95 100644 --- a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_config/instances.yml +++ b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/instances.yml @@ -1,3 +1,3 @@ instance-001: instance-002: -instance-003: \ No newline at end of file +instance-003: diff --git a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/myapp.lua b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/myapp.lua similarity index 99% rename from doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/myapp.lua rename to doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/myapp.lua index 5a489d1eec..c4cc0c25fb 100644 --- a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/myapp.lua +++ b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started/myapp.lua @@ -17,4 +17,4 @@ end function select_data() box.space.bands:select { 3 } -end \ No newline at end of file +end diff --git a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/instances.yml b/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/instances.yml deleted file mode 100644 index cb21a1f662..0000000000 --- a/doc/code_snippets/snippets/config/instances.enabled/tcm_get_started_tt/instances.yml +++ /dev/null @@ -1,3 +0,0 @@ -instance-001: -instance-002: -instance-003: \ No newline at end of file diff --git a/doc/how-to/getting_started_tcm.rst b/doc/how-to/getting_started_tcm.rst index d30b499bdf..27ef358378 100644 --- a/doc/how-to/getting_started_tcm.rst +++ b/doc/how-to/getting_started_tcm.rst @@ -8,6 +8,8 @@ Getting started with Tarantool Cluster Manager This tutorial uses `Tarantool Enterprise Edition `_. +**Example on GitHub**: `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. @@ -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 ` 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: @@ -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: @@ -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: @@ -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: @@ -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|: