Skip to content

Commit 19fd524

Browse files
committed
Document CLI options
1 parent 6fafa8a commit 19fd524

File tree

3 files changed

+247
-83
lines changed

3 files changed

+247
-83
lines changed

docs/src/main/sphinx/installation/cli.rst

Lines changed: 243 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,176 @@ Requirements
1313
The CLI requires a Java virtual machine available on the path.
1414
It can be used with Java version 8 and higher.
1515

16+
The CLI uses the :doc:`Trino client REST API
17+
</develop/client-protocol>` over HTTP/HTTPS to communicate with the
18+
coordinator on the cluster.
19+
1620
Installation
1721
------------
1822

19-
Download :maven_download:`cli`, rename it to ``trino``,
20-
make it executable with ``chmod +x``, then run it:
23+
Download :maven_download:`cli`, rename it to ``trino``, make it executable with
24+
``chmod +x``, and run it to show the version of the CLI:
25+
26+
.. code-block:: text
27+
28+
./trino --version
29+
30+
Run the CLI with ``--help`` or ``-h`` to see all available options.
31+
32+
Running the CLI
33+
---------------
34+
35+
The minimal command to start the CLI in interactive mode specifies the URL of
36+
the coordinator in the Trino cluster:
37+
38+
.. code-block:: text
39+
40+
./trino --server http://trino.example.com:8080
41+
42+
If successful, you will get a prompt to execute commands. Use the ``help``
43+
command to see a list of supported commands. Use the ``clear`` command to clear
44+
the terminal. To stop and exit the CLI, run ``exit`` or ``quit``.:
45+
46+
.. code-block:: text
47+
48+
trino> help
49+
50+
Supported commands:
51+
QUIT
52+
EXIT
53+
CLEAR
54+
EXPLAIN [ ( option [, ...] ) ] <query>
55+
options: FORMAT { TEXT | GRAPHVIZ | JSON }
56+
TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
57+
DESCRIBE <table>
58+
SHOW COLUMNS FROM <table>
59+
SHOW FUNCTIONS
60+
SHOW CATALOGS [LIKE <pattern>]
61+
SHOW SCHEMAS [FROM <catalog>] [LIKE <pattern>]
62+
SHOW TABLES [FROM <schema>] [LIKE <pattern>]
63+
USE [<catalog>.]<schema>
64+
65+
You can now run SQL statements. After processing, the CLI will show results and
66+
statistics.
67+
68+
.. code-block:: text
69+
70+
trino> SELECT count(*) FROM tpch.tiny.nation;
71+
72+
_col0
73+
-------
74+
25
75+
(1 row)
76+
77+
Query 20220324_213359_00007_w6hbk, FINISHED, 1 node
78+
Splits: 13 total, 13 done (100.00%)
79+
2.92 [25 rows, 0B] [8 rows/s, 0B/s]
80+
81+
As part of starting the CLI, you can set the default catalog and schema. This
82+
allows you to query tables directly without specifying catalog and schema.
83+
84+
.. code-block:: text
85+
86+
./trino --server http://trino.example.com:8080 --catalog tpch --schema tiny
87+
88+
trino:tiny> SHOW TABLES;
89+
90+
Table
91+
----------
92+
customer
93+
lineitem
94+
nation
95+
orders
96+
part
97+
partsupp
98+
region
99+
supplier
100+
(8 rows)
101+
102+
You can also set the default catalog and schema with the :doc:`/sql/use`
103+
statement.
21104

22105
.. code-block:: text
23106
24-
./trino --server localhost:8080 --catalog hive --schema default
107+
trino> USE tpch.tiny;
108+
USE
109+
trino:tiny>
25110
26-
Run the CLI with the ``--help`` option to see the available options.
111+
Many other options are available to further configure the CLI in interactive
112+
mode:
27113

28-
The CLI uses the HTTP protocol and the
29-
:doc:`Trino client REST API </develop/client-protocol>` to communicate
30-
with Trino.
114+
.. list-table::
115+
:widths: 40, 60
116+
:header-rows: 1
117+
118+
* - Option
119+
- Description
120+
* - ``--catalog``
121+
- Sets the default catalog. You can change the default catalog and schema
122+
with :doc:`/sql/use`.
123+
* - ``--client-info``
124+
- Adds arbitrary text as extra information about the client.
125+
* - ``--client-request-timeout``
126+
- Sets the duration for query processing, after which, the client request is
127+
terminated. Defaults to ``2m``.
128+
* - ``--client-tags``
129+
- Adds extra tags information about the client and the CLI user. Separate
130+
multiple tags with commas. The tags can be used as input for
131+
:doc:`/admin/resource-groups`.
132+
* - ``--debug``
133+
- Enables display of debug information during CLI usage for
134+
:ref:`cli-troubleshooting`. Displays more information about query
135+
processing statistics.
136+
* - ``--disable-compression``
137+
- Disables compression of query results.
138+
* - ``--editing-mode``
139+
- Sets key bindings in the CLI to be compatible with VI or
140+
EMACS editors. Defaults to ``EMACS``.
141+
* - ``--http-proxy``
142+
- Configures the URL of the HTTP proxy to connect to Trino.
143+
* - ``--network-logging``
144+
- Configures the level of detail provided for network logging of the CLI.
145+
Defaults to ``NONE``, other options are ``BASIC``, ``HEADERS``, or
146+
``BODY``.
147+
* - ``--password``
148+
- Prompts for a password. Use if your Trino server requires password
149+
authentication. You can set the ``TRINO_PASSWORD`` environment variable
150+
with the password value to avoid the prompt. For more information, see :ref:`cli-username-password-auth`.
151+
* - ``--schema``
152+
- Sets the default schema. You can change the default catalog and schema
153+
with :doc:`/sql/use`.
154+
* - ``--server``
155+
- The HTTP/HTTPS address and port of the Trino coordinator. The port must be
156+
set to the port the Trino coordinator is listening for connections on.
157+
Trino server location defaults to ``http://localhost:8080``.
158+
* - ``--session``
159+
- Sets one or more :ref:`session properties
160+
<session-properties-definition>`. Property can be used multiple times with
161+
the format ``session_property_name=value``.
162+
* - ``--socks-proxy``
163+
- Configures the URL of the SOCKS proxy to connect to Trino.
164+
* - ``--source``
165+
- Specifies the name of the application or source connecting to Trino.
166+
Defaults to ``trino-cli``. The value can be used as input for
167+
:doc:`/admin/resource-groups`.
168+
* - ``--timezone``
169+
- Sets the time zone for the session using the `time zone name
170+
<https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`_. Defaults
171+
to the timezone set on your workstation.
172+
* - ``--user``
173+
- Sets the username for :ref:`cli-username-password-auth`. Defaults to your
174+
operating system username. You can override the default username,
175+
if your cluster uses a different username or authentication mechanism.
176+
177+
.. _cli-tls:
31178

32179
TLS/HTTPS
33180
---------
34181

35182
Trino is typically available with an HTTPS URL. This means that all network
36183
traffic between the CLI and Trino uses TLS. :doc:`TLS configuration
37-
</security/tls>` is common, since it is a requirement for any authentication.
184+
</security/tls>` is common, since it is a requirement for :ref:`any
185+
authentication <cli-authentication>`.
38186

39187
Use the HTTPS URL to connect to the server:
40188

@@ -46,36 +194,58 @@ The recommended TLS implementation is to use a globally trusted certificate. In
46194
this case, no other options are necessary, since the JVM running the CLI
47195
recognizes these certificates.
48196

49-
Use ``--help`` to see information about specifying the keystore, truststore, and
50-
other authentication details as required.
197+
Use the options from the following table to further configure TLS and
198+
certificate usage:
199+
200+
.. list-table::
201+
:widths: 40, 60
202+
:header-rows: 1
203+
204+
* - Option
205+
- Description
206+
* - ``--insecure``
207+
- Skip certificate validation when connecting with TLS/HTTPS (should only be
208+
used for debugging).
209+
* - ``--keystore-path``
210+
- The location of the Java Keystore file that contains the certificate of
211+
the server to connect with TLS.
212+
* - ``--keystore-password``
213+
- The password for the keystore. This must match the password you specified
214+
when creating the keystore.
215+
* - ``--keystore-type``
216+
- Keystore type.
217+
* - ``--truststore-password``
218+
- The password for the truststore. This must match the password you
219+
specified when creating the truststore.
220+
* - ``--truststore-path``
221+
- The location of the Java truststore file that will be used to secure TLS.
222+
* - ``--truststore-type``
223+
- Truststore type.
224+
225+
.. _cli-authentication:
51226

52227
Authentication
53228
--------------
54229

55230
The Trino CLI supports many :doc:`/security/authentication-types` detailed in
56231
the following sections:
57232

233+
.. _cli-username-password-auth:
234+
58235
Username and password authentication
59236
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60237

61-
Username and password authentication is typically configured in a cluster with
62-
the ``PASSWORD`` authentication type.
63-
64-
If your Trino server requires password authentication, use the ``--password``
65-
option to have the CLI prompt for a password. If your cluster uses a different
66-
username, you can override your username with the ``--user`` option. It defaults
67-
to your operating system username.
238+
Username and password authentication is typically configured in a cluster using
239+
the ``PASSWORD`` :doc:`authentication type </security/authentication-types>`,
240+
for example with :doc:`/security/ldap` or :doc:`/security/password-file`.
68241

69242
The following code example connects to the server, establishes your user name,
70243
and prompts the CLI for your password:
71244

72-
.. code-block:: text
245+
.. code-block:: text
73246
74247
./trino --server https://trino.example.com --user=myusername --password
75248
76-
You can set the ``TRINO_PASSWORD`` environment variable with the password value
77-
to avoid the prompt.
78-
79249
.. _cli-external-sso-auth:
80250

81251
External authentication - SSO
@@ -134,11 +304,57 @@ JWT authentication
134304
To access a Trino cluster configured to use :doc:`/security/jwt`, use the
135305
``--access-token=<token>`` option to pass a JWT to the server.
136306

307+
.. _cli-kerberos-auth:
308+
137309
Kerberos authentication
138310
^^^^^^^^^^^^^^^^^^^^^^^
139311

140-
If your cluster is secured with Kerberos authentication, see
141-
:doc:`/security/cli`.
312+
In addition to the options that are required when connecting to an unauthorized
313+
Trino coordinator, invoking the CLI with Kerberos support enabled requires a
314+
number of additional command line options. The simplest way to invoke the CLI is
315+
with a wrapper script.
316+
317+
.. code-block:: text
318+
319+
#!/bin/bash
320+
321+
./trino \
322+
--server https://trino-coordinator.example.com:7778 \
323+
--krb5-config-path /etc/krb5.conf \
324+
--krb5-principal someuser@EXAMPLE.COM \
325+
--krb5-keytab-path /home/someuser/someuser.keytab \
326+
--krb5-remote-service-name trino \
327+
--keystore-path /tmp/trino.jks \
328+
--keystore-password password \
329+
--catalog <catalog> \
330+
--schema <schema>
331+
332+
The following table list the available options for Kerberos authentication:
333+
334+
.. list-table:: CLI options for Kerberos authentication
335+
:widths: 40, 60
336+
:header-rows: 1
337+
338+
* - Option
339+
- Description
340+
* - ``--krb5-config-path``
341+
- Path to Kerberos configuration files.
342+
* - ``--krb5-credential-cache-path``
343+
- Kerberos credential cache path.
344+
* - ``--krb5-disable-remote-service-hostname-canonicalization``
345+
- Disable service hostname canonicalization using the DNS reverse lookup.
346+
* - ``--krb5-keytab-path``
347+
- The location of the keytab that can be used to authenticate the principal
348+
specified by ``--krb5-principal``.
349+
* - ``--krb5-principal``
350+
- The principal to use when authenticating to the coordinator.
351+
* - ``--krb5-remote-service-name``
352+
- Trino coordinator Kerberos service name.
353+
* - ``--krb5-service-principal-pattern``
354+
- Remote kerberos service principal pattern (default: ${SERVICE}@${HOST})
355+
356+
See :doc:`/security/cli` for more information on configuring and using Kerberos
357+
with the CLI.
142358

143359
Pagination
144360
----------
@@ -160,6 +376,8 @@ press :kbd:`Enter`.
160376
By default, you can locate the Trino history file in ``~/.trino_history``.
161377
Use the ``TRINO_HISTORY_FILE`` environment variable to change the default.
162378

379+
.. _cli-output-format:
380+
163381
Output Formats
164382
--------------
165383

@@ -260,6 +478,8 @@ and displays an error message (which is unaffected by the output format):
260478
Query 20200707_170726_00030_2iup9 failed: line 1:25: Column 'region' cannot be resolved
261479
SELECT nationkey, name, region FROM tpch.sf1.nation LIMIT 3
262480
481+
.. _cli-troubleshooting:
482+
263483
Troubleshooting
264484
---------------
265485

@@ -286,4 +506,3 @@ To view debug information, including the stack trace for failures, use the
286506
...
287507
at java.base/java.lang.Thread.run(Thread.java:834)
288508
select count(*) from tpch.tiny.nations
289-

docs/src/main/sphinx/security/cli.rst

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,44 +41,9 @@ through HTTPS. If you have not yet configured HTTPS/TLS for your coordinator,
4141
refer to :doc:`HTTPS and TLS </security/tls>`.
4242

4343
Trino CLI execution
44-
--------------------
44+
-------------------
4545

46-
In addition to the options that are required when connecting to a Trino
47-
coordinator, that does not require Kerberos authentication, invoking the CLI
48-
with Kerberos support enabled requires a number of additional command line
49-
options. The simplest way to invoke the CLI is with a wrapper script.
50-
51-
.. code-block:: text
52-
53-
#!/bin/bash
54-
55-
./trino \
56-
--server https://trino-coordinator.example.com:7778 \
57-
--krb5-config-path /etc/krb5.conf \
58-
--krb5-principal someuser@EXAMPLE.COM \
59-
--krb5-keytab-path /home/someuser/someuser.keytab \
60-
--krb5-remote-service-name trino \
61-
--keystore-path /tmp/trino.jks \
62-
--keystore-password password \
63-
--catalog <catalog> \
64-
--schema <schema>
65-
66-
=============================== =========================================================================
67-
Option Description
68-
=============================== =========================================================================
69-
``--server`` The address and port of the Trino coordinator. The port must
70-
be set to the port the Trino coordinator is listening for HTTPS
71-
connections on.
72-
``--krb5-config-path`` Kerberos configuration file.
73-
``--krb5-principal`` The principal to use when authenticating to the coordinator.
74-
``--krb5-keytab-path`` The location of the keytab that can be used to
75-
authenticate the principal specified by ``--krb5-principal``
76-
``--krb5-remote-service-name`` Trino coordinator Kerberos service name.
77-
``--keystore-path`` The location of the Java Keystore file that is used
78-
to secure TLS.
79-
``--keystore-password`` The password for the keystore. This must match the
80-
password you specified when creating the keystore.
81-
=============================== =========================================================================
46+
Use the :ref:`Kerberos options to run the CLI <cli-kerberos-auth>`.
8247

8348
Troubleshooting
8449
---------------

0 commit comments

Comments
 (0)