Managing multiple instances
tt utility can manage Tarantool applications that run on
multiple instances. With a single
tt call, you can:
- start an application on multiple instances (tt start)
- check the status of application instances (tt status)
- connect to a specific instance of an application (tt connect)
- stop a specific instance of an application or all its instances (tt stop)
To create an application that runs on multiple instances, prepare its configuration in a directory. The directory name is used as the application’s identifier.
This directory should contain the following files:
The application file named
The instances configuration file
instances.ymlwith instance names followed by colons:
<instance_name1>: <instance_name2>: ...
Do not use the dot (
.) and dash (
-) characters in the instance names. They are reserved for system use.
(Optional) Application files to run on specific instances. These files should have names
<instance_name>is the name specified in
instances.yml. For example, if your application has separate source files for the
storageinstances, place the router code in the
When the application is working, each instance has associated environment variables
TARANTOOL_APP_NAME. You can use them in the application
code to identify the instance on which the code runs.
To obtain the instance and application names, use the following code:
local inst_name = os.getenv('TARANTOOL_INSTANCE_NAME') local app_name = os.getenv('TARANTOOL_APP_NAME')
demo application runs on three instances:
storing data and
router for connections.
the same code, and
router has its own code.
The application configuration is stored in the
demo directory. The directory
contains the following files:
instances.yml– the instances configuration:
master: replica: router:
init.lua– the code of
router.init.lua– the code of
Start all three instances of the
tt start demo
Check the status of
tt status demo
Check the status of a specific instance:
tt status demo:replica
Connect to an instance:
tt connect demo:router
Stop a specific instance:
tt stop demo:replica
tt stop demo