Skip to content

Commit 41aaa14

Browse files
p7novandreyaksenov
andauthored
Replace tarantoolctl with tt (CE part) (#3706)
Resolves #3501 Also: fixes build warnings Co-authored-by: Kseniia Antonova <[email protected]> Co-authored-by: Andrey Aksenov <[email protected]>
1 parent 2824070 commit 41aaa14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+600
-378
lines changed

doc/archive/shard.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ To acquire it, do a separate installation:
8181

8282
.. code-block:: console
8383
84-
$ tarantoolctl rocks install shard
84+
$ tt rocks install shard
8585
8686
* install with `yum` or `apt`, for example on Ubuntu say:
8787

doc/book/admin/daemon_supervision.rst

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ an instance:
5757
5858
$ systemctl status tarantool@my_app|grep PID
5959
Main PID: 5885 (tarantool)
60-
$ tarantoolctl enter my_app
61-
/bin/tarantoolctl: Found my_app.lua in /etc/tarantool/instances.available
62-
/bin/tarantoolctl: Connecting to /var/run/tarantool/my_app.control
63-
/bin/tarantoolctl: connected to unix/:/var/run/tarantool/my_app.control
64-
unix/:/var/run/tarantool/my_app.control> os.exit(-1)
65-
/bin/tarantoolctl: unix/:/var/run/tarantool/my_app.control: Remote host closed connection
60+
$ tt connect my_app
61+
• Connecting to the instance...
62+
• Connected to /var/run/tarantool/my_app.control
63+
/var/run/tarantool/my_app.control> os.exit(-1)
64+
⨯ Connection was closed. Probably instance process isn't running anymore
6665
6766
Now let’s make sure that ``systemd`` has restarted the instance:
6867

@@ -71,20 +70,11 @@ Now let’s make sure that ``systemd`` has restarted the instance:
7170
$ systemctl status tarantool@my_app|grep PID
7271
Main PID: 5914 (tarantool)
7372
74-
Finally, let’s check the boot logs:
73+
Additionally, you can find the information about the instance restart in the boot logs:
7574

7675
.. code-block:: console
7776
7877
$ journalctl -u tarantool@my_app -n 8
79-
-- Logs begin at Fri 2016-01-08 12:21:53 MSK, end at Thu 2016-01-21 21:09:45 MSK. --
80-
Jan 21 21:09:45 localhost.localdomain systemd[1]: tarantool@my_app.service: Unit entered failed state.
81-
Jan 21 21:09:45 localhost.localdomain systemd[1]: tarantool@my_app.service: Failed with result 'exit-code'.
82-
Jan 21 21:09:45 localhost.localdomain systemd[1]: tarantool@my_app.service: Service hold-off time over, scheduling restart.
83-
Jan 21 21:09:45 localhost.localdomain systemd[1]: Stopped Tarantool Database Server.
84-
Jan 21 21:09:45 localhost.localdomain systemd[1]: Starting Tarantool Database Server...
85-
Jan 21 21:09:45 localhost.localdomain tarantoolctl[5910]: /usr/bin/tarantoolctl: Found my_app.lua in /etc/tarantool/instances.available
86-
Jan 21 21:09:45 localhost.localdomain tarantoolctl[5910]: /usr/bin/tarantoolctl: Starting instance...
87-
Jan 21 21:09:45 localhost.localdomain systemd[1]: Started Tarantool Database Server.
8878
8979
.. _admin-core_dumps:
9080

@@ -118,9 +108,11 @@ instance:
118108
.. code-block:: console
119109
120110
$ # !!! please never do this on a production system !!!
121-
$ tarantoolctl enter my_app
122-
unix/:/var/run/tarantool/my_app.control> require('ffi').cast('char *', 0)[0] = 48
123-
/bin/tarantoolctl: unix/:/var/run/tarantool/my_app.control: Remote host closed connection
111+
$ tt connect my_app
112+
• Connecting to the instance...
113+
• Connected to /var/run/tarantool/my_app.control
114+
/var/run/tarantool/my_app.control> require('ffi').cast('char *', 0)[0] = 48
115+
⨯ Connection was closed. Probably instance process isn't running anymore
124116
125117
Alternatively, if you know the process ID of the instance (here we refer to it
126118
as $PID), you can abort a Tarantool instance by running ``gdb`` debugger:

doc/book/admin/disaster_recovery.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ transferred to the replica before crash. If you were able to salvage the master
7878

7979
.. code-block:: console
8080
81-
$ tarantoolctl <new_master_uri> <xlog_file> play --from 23425 --replica 1
81+
$ tt play <new_master_uri> <xlog_file> --from 23425 --replica 1
8282
8383
.. _admin-disaster_recovery-master_master:
8484

@@ -118,9 +118,9 @@ Your actions:
118118
made with older checkpoints until :doc:`/reference/reference_lua/box_backup/stop` is called.
119119

120120
2. Get the latest valid :ref:`.snap file <internals-snapshot>` and
121-
use ``tarantoolctl cat`` command to calculate at which lsn the data loss occurred.
121+
use ``tt cat`` command to calculate at which lsn the data loss occurred.
122122

123-
3. Start a new instance (instance#1) and use ``tarantoolctl play`` command to
123+
3. Start a new instance (instance#1) and use ``tt play`` command to
124124
play to it the contents of .snap/.xlog files up to the calculated lsn.
125125

126126
4. Bootstrap a new replica from the recovered master (instance#1).

doc/book/admin/index.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33

44
.. _admin:
55

6-
********************************************************************************
76
Administration
8-
********************************************************************************
7+
==============
98

109
Tarantool is designed to have multiple running instances on the same host.
1110

1211
Here we show how to administer Tarantool instances using any of the following
1312
utilities:
1413

1514
* ``systemd`` native utilities, or
16-
* :ref:`tarantoolctl <tarantoolctl>`, an administrative utility shipped and installed as
17-
part of Tarantool distribution.
15+
* :ref:`tt <tt-cli>`, a command-line utility for managing Tarantool-based applications.
1816

1917
.. NOTE::
2018

doc/book/admin/instance_config.rst

Lines changed: 19 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ For each Tarantool instance, you need two files:
2828
* An :ref:`instance file <admin-instance_file>` with
2929
instance-specific initialization logic and parameters. Put this file, or a
3030
symlink to it, into the **instance directory**
31-
(see :ref:`instance_dir <admin-instance_dir>` parameter in ``tarantoolctl``
32-
configuration file).
31+
(see ``instances_enabled`` parameter in :ref:`tt configuration file <tt-config_file>`).
3332

3433
For example, ``/etc/tarantool/instances.enabled/my_app.lua`` (here we load
3534
``my_app.lua`` module and make a call to ``start()`` function from that
@@ -53,7 +52,7 @@ Instance file
5352
-------------
5453

5554
After this short introduction, you may wonder what an instance file is, what it
56-
is for, and how ``tarantoolctl`` uses it. After all, Tarantool is an application
55+
is for, and how ``tt`` uses it. After all, Tarantool is an application
5756
server, so why not start the application stored in ``/usr/share/tarantool``
5857
directly?
5958

@@ -76,7 +75,7 @@ An instance file is designed to not differ in any way from a Lua application.
7675
It must, however, configure the database, i.e. contain a call to
7776
:doc:`box.cfg{} </reference/reference_lua/box_cfg>` somewhere in it, because it’s the
7877
only way to turn a Tarantool script into a background process, and
79-
``tarantoolctl`` is a tool to manage background processes. Other than that, an
78+
``tt`` is a tool to manage background processes. Other than that, an
8079
instance file may contain arbitrary Lua code, and, in theory, even include the
8180
entire application business logic in it. We, however, do not recommend this,
8281
since it clutters the instance file and leads to unnecessary copy-paste when
@@ -155,82 +154,24 @@ You get the following output:
155154
If an error happens during the execution of the preload script or module, Tarantool
156155
reports the problem and exits.
157156

158-
.. _admin-tarantoolctl_config_file:
157+
.. _admin-tt_config_file:
159158

160-
tarantoolctl configuration file
161-
-------------------------------
159+
tt configuration file
160+
---------------------
162161

163-
While instance files contain instance configuration, the ``tarantoolctl``
164-
configuration file contains the configuration that ``tarantoolctl`` uses to
165-
override instance configuration. In other words, it contains system-wide
166-
configuration defaults. If ``tarantoolctl`` fails to find this file with
167-
the method described in section
168-
:ref:`Starting/stopping an instance <admin-start_stop_instance>`, it uses
169-
default settings.
162+
While instance files contain instance configuration, the :ref:`tt <tt-cli>` configuration file
163+
contains the configuration that ``tt`` uses to set up the application environment.
164+
This includes the path to instance files, various working directories, and other
165+
parameters that connect the application to the system.
170166

171-
Most of the parameters are similar to those used by
172-
:doc:`box.cfg{} </reference/reference_lua/box_cfg>`. Here are the default settings
173-
(possibly installed in ``/etc/default/tarantool`` or ``/etc/sysconfig/tarantool``
174-
as part of Tarantool distribution -- see OS-specific default paths in
175-
:ref:`Notes for operating systems <admin-os_notes>`):
167+
To create a default ``tt`` configuration, run ``tt init``. This creates a ``tt.yaml``
168+
configuration file. Its location depends on the :ref:`tt launch mode <tt-config_modes>`
169+
(system or local).
176170

177-
.. code-block:: lua
178-
179-
default_cfg = {
180-
pid_file = "/var/run/tarantool",
181-
wal_dir = "/var/lib/tarantool",
182-
memtx_dir = "/var/lib/tarantool",
183-
vinyl_dir = "/var/lib/tarantool",
184-
log = "/var/log/tarantool",
185-
username = "tarantool",
186-
language = "Lua",
187-
}
188-
instance_dir = "/etc/tarantool/instances.enabled"
189-
190-
where:
191-
192-
* | ``pid_file``
193-
| Directory for the pid file and control-socket file; ``tarantoolctl`` will
194-
add “/instance_name” to the directory name.
195-
196-
* | ``wal_dir``
197-
| Directory for write-ahead .xlog files; ``tarantoolctl`` will add
198-
"/instance_name" to the directory name.
199-
200-
* | ``memtx_dir``
201-
| Directory for snapshot .snap files; ``tarantoolctl`` will add
202-
"/instance_name" to the directory name.
203-
204-
* | ``vinyl_dir``
205-
| Directory for vinyl files; ``tarantoolctl`` will add "/instance_name" to the
206-
directory name.
207-
208-
* | ``log``
209-
| The place where the application log will go; ``tarantoolctl`` will add
210-
"/instance_name.log" to the name.
211-
212-
* | ``username``
213-
| The user that runs the Tarantool instance. This is the operating-system user
214-
name rather than the Tarantool-client user name. Tarantool will change its
215-
effective user to this user after becoming a daemon.
216-
217-
* | ``language``
218-
| The :ref:`interactive console <interactive_console>` language. Can be either ``Lua`` or ``SQL``.
219-
220-
.. _admin-instance_dir:
221-
222-
* | ``instance_dir``
223-
| The directory where all instance files for this host are stored. Put
224-
instance files in this directory, or create symbolic links.
225-
226-
The default instance directory depends on Tarantool's ``WITH_SYSVINIT``
227-
build option: when ON, it is ``/etc/tarantool/instances.enabled``,
228-
otherwise (OFF or not set) it is ``/etc/tarantool/instances.available``.
229-
The latter case is typical for Tarantool builds for Linux distros with
230-
``systemd``.
231-
232-
To check the build options, say ``tarantool --version``.
171+
Some ``tt`` configuration parameters are similar to those used by
172+
:doc:`box.cfg{} </reference/reference_lua/box_cfg>`, for example, ``memxt_dir``
173+
or ``wal_dir``. Other parameters define the ``tt`` environment, for example,
174+
paths to installation files used by ``tt`` or to connected :ref:`external modules <tt-external_modules>`.
233175

234-
As a full-featured example, you can take
235-
`example.lua <https://github.com/tarantool/tarantool/blob/2.1/extra/dist/example.lua>`_
236-
script that ships with Tarantool and defines all configuration options.
176+
Find the detailed information about the ``tt`` configuration parameters and launch modes
177+
on the :ref:`tt configuration page <tt-config>`.

doc/book/admin/logs.rst

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,92 @@
11
.. _admin-logs:
22

3-
================================================================================
43
Logs
5-
================================================================================
4+
====
65

7-
Tarantool logs important events to a file, e.g. ``/var/log/tarantool/my_app.log``.
8-
To build the log file path, ``tarantoolctl`` takes the instance name, prepends
9-
the instance directory and appends “.log” extension.
6+
Each Tarantool instance logs important events to its own log file ``<instance-name>.log``.
7+
For instances started with :ref:`tt <tt-cli>`, the log location is defined by
8+
the ``log_dir`` parameter in the :ref:`tt configuration <tt-config>`.
9+
By default, it's ``/var/log/tarantool`` in the ``tt`` :ref:`system mode <tt-config_modes>`,
10+
and the ``var/log/`` subdirectory of the ``tt`` working directory in the :ref:`local mode <tt-config_modes>`.
11+
In the specified location, ``tt`` creates separate directories for each instance's logs.
1012

11-
Let’s write something to the log file:
13+
To check how logging works, write something to the log using the :ref:`log <log-module>` module:
1214

1315
.. code-block:: console
1416
15-
$ tarantoolctl enter my_app
16-
/bin/tarantoolctl: connected to unix/:/var/run/tarantool/my_app.control
17-
unix/:/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers")
18-
---
19-
...
17+
$ tt connect my_app
18+
• Connecting to the instance...
19+
• Connected to /var/run/tarantool/my_app.control
20+
21+
/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers")
2022
2123
Then check the logs:
2224

2325
.. code-block:: console
2426
2527
$ tail /var/log/tarantool/my_app.log
26-
2017-04-04 15:54:04.977 [29255] main/101/tarantoolctl C> version 1.7.3-382-g68ef3f6a9
27-
2017-04-04 15:54:04.977 [29255] main/101/tarantoolctl C> log level 5
28-
2017-04-04 15:54:04.978 [29255] main/101/tarantoolctl I> mapping 134217728 bytes for tuple arena...
29-
2017-04-04 15:54:04.985 [29255] iproto/101/main I> binary: bound to [::1]:3301
30-
2017-04-04 15:54:04.986 [29255] main/101/tarantoolctl I> recovery start
31-
2017-04-04 15:54:04.986 [29255] main/101/tarantoolctl I> recovering from `/var/lib/tarantool/my_app/00000000000000000000.snap'
32-
2017-04-04 15:54:04.988 [29255] main/101/tarantoolctl I> ready to accept requests
33-
2017-04-04 15:54:04.988 [29255] main/101/tarantoolctl I> set 'checkpoint_interval' configuration option to 3600
34-
2017-04-04 15:54:04.988 [29255] main/101/my_app I> Run console at unix/:/var/run/tarantool/my_app.control
35-
2017-04-04 15:54:04.989 [29255] main/106/console/unix/:/var/ I> started
36-
2017-04-04 15:54:04.989 [29255] main C> entering the event loop
37-
2017-04-04 15:54:47.147 [29255] main/107/console/unix/: I> Hello for the manual readers
28+
2023-09-12 18:13:00.396 [67173] main/111/guard of feedback_daemon/box.feedback_daemon V> metrics_collector restarted
29+
2023-09-12 18:13:00.396 [67173] main/103/-/box.feedback_daemon V> feedback_daemon started
30+
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(14) = 0x1090077b4
31+
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(26) = 0x1090077ec
32+
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007824
33+
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(24) = 0x10900785c
34+
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007894
35+
2023-09-12 18:13:00.396 [67173] main/106/checkpoint_daemon I> scheduled next checkpoint for Tue Sep 12 19:44:34 2023
36+
2023-09-12 18:13:00.396 [67173] main I> entering the event loop
37+
2023-09-12 18:13:11.656 [67173] main/114/console/unix/:/tarantool I> Hello for the manual readers
38+
39+
.. _admin-logs-rotation:
40+
41+
Log rotation
42+
------------
3843

3944
When :ref:`logging to a file <cfg_logging-log>`, the system administrator must ensure logs are
40-
rotated timely and do not take up all the available disk space. With
41-
``tarantoolctl``, log rotation is pre-configured to use ``logrotate`` program,
42-
which you must have installed.
43-
44-
File ``/etc/logrotate.d/tarantool`` is part of the standard Tarantool
45-
distribution, and you can modify it to change the default behavior. This is what
46-
this file is usually like:
47-
48-
.. code-block:: text
49-
50-
/var/log/tarantool/*.log {
51-
daily
52-
size 512k
53-
missingok
54-
rotate 10
55-
compress
56-
delaycompress
57-
create 0640 tarantool adm
58-
postrotate
59-
/usr/bin/tarantoolctl logrotate `basename ${1%%.*}`
60-
endscript
61-
}
62-
63-
If you use a different log rotation program, you can invoke
64-
``tarantoolctl logrotate`` command to request instances to reopen their log
65-
files after they were moved by the program of your choice.
66-
67-
Tarantool can write its logs to a log file, ``syslog`` or a program specified
68-
in the configuration file (see :ref:`log <cfg_logging-log>` parameter).
69-
70-
By default, logs are written to a file as defined in ``tarantoolctl``
71-
defaults. ``tarantoolctl`` automatically detects if an instance is using
72-
``syslog`` or an external program for logging, and does not override the log
73-
destination in this case. In such configurations, log rotation is usually
74-
handled by the external program used for logging. So,
75-
``tarantoolctl logrotate`` command works only if logging-into-file is enabled
76-
in the instance file.
45+
rotated timely and do not take up all the available disk space.
46+
To prevent log files from growing infinitely, ``tt`` automatically rotates instance
47+
logs. The following ``tt`` configuration parameters define the log rotation:
48+
``log_maxsize`` (in megabytes) and ``log_maxage`` (in days). When any of these
49+
limits is reached, the log is rotated.
50+
Additionally, there is the ``log_maxbackups`` parameter (the number of stored log
51+
files for an instance), which enables automatic removal of old log files.
52+
53+
.. code-block:: yaml
54+
55+
# tt.yaml
56+
tt:
57+
app:
58+
log_maxsize: 100
59+
log_maxage: 3
60+
log_maxbackups: 50
61+
# ...
62+
63+
There is also the :ref:`tt logrotate <tt-logrotate>` command that performs log
64+
rotation on demand.
65+
66+
.. code-block:: bash
67+
68+
tt logrotate my_app
69+
70+
To learn about log rotation in the deprecated ``tarantoolctl`` utility,
71+
check its :ref:`documentation <tarantoolctl-log-rotation>`.
72+
73+
74+
.. _admin-logs-formats:
75+
76+
Log formats
77+
-----------
78+
79+
Tarantool can write its logs to a log file, to ``syslog``, or to a specified program
80+
through a pipe.
81+
82+
File is the default log format for ``tt``. To send logs to a pipe or ``syslog``,
83+
specify the :ref:`box.cfg.log <cfg_logging-log>` parameter, for example:
84+
85+
.. code-block:: lua
86+
87+
box.cfg{log = '| cronolog tarantool.log'}
88+
-- or
89+
box.cfg{log = 'syslog:identity=tarantool,facility=user'}
90+
91+
In such configurations, log rotation is usually handled by the external program
92+
used for logging.

0 commit comments

Comments
 (0)