|
| 1 | +.. _tcm_cluster_data_access: |
| 2 | + |
| 3 | +Accessing cluster data |
| 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| provides access to data stored in connected clusters through its |
| 11 | +web interface. You can view, add, edit, and delete tuples from spaces. |
| 12 | + |
| 13 | +.. note:: |
| 14 | + |
| 15 | + A |TCM| user's access to specific clusters and spaces is determined by their |
| 16 | + :ref:`cluster permissions <tcm_access_control_permissions>` and :ref:`access control list <tcm_access_control_acl>`. |
| 17 | + |
| 18 | +Data access is implemented in |tcm| on a per-instance basis: you can access |
| 19 | +data stored on one cluster instance at a time. For sharded clusters that use the |
| 20 | +`CRUD <https://github.com/tarantool/crud>`__ module, |
| 21 | +it's also possible to access data throughout the whole cluster. |
| 22 | + |
| 23 | +.. _tcm_cluster_data_access_instance: |
| 24 | + |
| 25 | +Instance data |
| 26 | +------------- |
| 27 | + |
| 28 | +There are the following ways to access data stored on a cluster instance from |tcm|: |
| 29 | + |
| 30 | +- **Instance explorer** displays the instance's spaces as tables in the web interface |
| 31 | +- **SQL terminal** allows executing SQL statements on the instance |
| 32 | +- **Tarantool and tt consoles** allow accessing the data using the Lua API |
| 33 | + |
| 34 | +.. important:: |
| 35 | + |
| 36 | + Data modification is possible only on instances in the read-write mode (replica set leaders). |
| 37 | + Changes are applied to read-only replicas in accordance with the cluster topology. |
| 38 | + |
| 39 | +.. _tcm_cluster_data_access_instance_explorer: |
| 40 | + |
| 41 | +Instance explorer |
| 42 | +~~~~~~~~~~~~~~~~~ |
| 43 | + |
| 44 | +The instance explorer provides access to all spaces that exist on the instances |
| 45 | +in the web interface. This includes both system and user spaces. |
| 46 | + |
| 47 | +To open the instance explorer: |
| 48 | + |
| 49 | +#. Go to **Stateboard**. |
| 50 | +#. Click the instance row in the instances list or its graph vertex in the graph view. |
| 51 | +#. Click **Explorer** in the **Actions menu** of the instance details page. |
| 52 | + |
| 53 | +To view tuples of a space, click its row in the spaces list. |
| 54 | + |
| 55 | +To add a new tuple, click **+** on the space page and provide tuple field values |
| 56 | +in the Lua format, for example, ``[ 1, 1000, true, "test"]``. |
| 57 | + |
| 58 | +To edit a tuple, click it in the table and then click **Edit**. |
| 59 | + |
| 60 | +To delete a tuple, select it in the table and click **Delete** (the trash bin button). |
| 61 | + |
| 62 | +In the development mode, you can also create, edit, truncate, and delete spaces |
| 63 | +in the instance explorer. To create a space, click **Add** and follow the wizard steps. |
| 64 | +To edit, truncate, or remove a space, click the corresponding button in the **Actions** |
| 65 | +menu of the space row in the table. |
| 66 | + |
| 67 | +.. _tcm_cluster_data_access_instance_sql: |
| 68 | + |
| 69 | +SQL terminal |
| 70 | +~~~~~~~~~~~~ |
| 71 | + |
| 72 | +|tcm| features an SQL terminal that you can use to access stored data. It is located |
| 73 | +on the **SQL** tab of the instance details page. In the SQL terminal, you can execute |
| 74 | +any :ref:`supported SQL expressions <sql_statements_and_clauses>` on the selected instance. |
| 75 | + |
| 76 | +For ``select`` SQL queries, you can also download the query result set in the CSV format. |
| 77 | + |
| 78 | +To learn more about using SQL in Tarantool, see the :ref:`sql_tutorial`. |
| 79 | + |
| 80 | +.. _tcm_cluster_data_access_instance_lua: |
| 81 | + |
| 82 | +Lua API: Tarantool and tt consoles |
| 83 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 84 | + |
| 85 | +|tcm| provides interactive access to instances' consoles on the **Terminal** tab |
| 86 | +of the instance details page. You can choose between the :ref:`tt console <tt-interactive-console>` |
| 87 | +(**TT Connect** tab) and :ref:`Tarantool interactive console <interactive_console>` (**Direct** tab). |
| 88 | + |
| 89 | +In these consoles, you can access the stored data using the Tarantool :ref:`Lua API <built_in_modules>`. |
| 90 | + |
| 91 | +.. _tcm_cluster_data_access_crud: |
| 92 | + |
| 93 | +Sharded cluster data |
| 94 | +-------------------- |
| 95 | + |
| 96 | +For sharded clusters that use the `CRUD <https://github.com/tarantool/crud>`__ module, |
| 97 | +it's possible to access stored data throughout the cluster on the **Cluster** > **Tuples** page. |
| 98 | +This page displays only user spaces. |
| 99 | + |
| 100 | +To view all tuples of a space in a sharded cluster, click the space row in the list. |
| 101 | + |
| 102 | +To add a new tuple, click **+** on the space page and provide tuple field values |
| 103 | +in the Lua format, for example ``[ 1, 1000, true, "test"]``. When you add a tuple |
| 104 | +in a sharded cluster, it is distributed to a replica set based on the sharding key |
| 105 | +(the ``bucket_id`` field) value. |
| 106 | + |
| 107 | +To edit a tuple, click it in the table and then click **Edit**. |
| 108 | + |
| 109 | +To delete a tuple, select it in the table and click **Delete** (the trash bin button). |
| 110 | + |
| 111 | + |
| 112 | +.. _tcm_cluster_data_access_crud_spaces: |
| 113 | + |
| 114 | +Creating spaces in sharded clusters |
| 115 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 116 | + |
| 117 | +To create a space in a sharded cluster, create it on all read-write cluster instances |
| 118 | +on their :ref:`Instance explorer <tcm_cluster_data_access_instance_explorer>` pages. |
| 119 | + |
| 120 | +.. important:: |
| 121 | + |
| 122 | + Sharded spaces must include the ``bucket_id`` field of the ``unsigned`` type |
| 123 | + and a non-unique index by this field with the same name. |
| 124 | + |
| 125 | +To edit, truncate, or delete spaces in a sharded cluster, perform the corresponding |
| 126 | +action on all read-write cluster instances. |
0 commit comments