After you create a cluster with the Trino service, you can use the command-line interface (CLI) to connect to Trino for quick and simple data queries.
Prerequisites
A cluster has been created with the Trino service selected. For more information about how to create a cluster, see Create a cluster.
Limitations
Ranger and Kerberos cannot be enabled in the same cluster simultaneously.
Datalake and custom clusters
Enabling Kerberos Authentication when you create a cluster creates a high-security cluster. Otherwise, a common cluster is created.
Common clusters
-
Log on to the cluster using SSH. For more information, see Log on to a cluster.
-
Run the following command to connect to the Trino CLI.
NoteFor E-MapReduce (EMR) 3.44.0 or later and EMR 5.10.0 or later, the console displays the service as Trino. For versions earlier than EMR 3.44.0 and EMR 5.10.0, the console displays the service as Presto.
EMR 3.44.0 or later and EMR 5.10.0 or later
trino --server master-1-1:9090Versions earlier than EMR 3.44.0 and EMR 5.10.0
presto --server master-1-1:9090 -
Run the following command to view table data.
select * from <catalog>.<schema>.<table>;The parameters in the command are as follows:
-
<catalog>: The name of the data source. -
<schema>: The name of the database. -
<table>: The table to query.For example, to view the data in the
testtable in the default database of a Hive data source, run theselect * from hive.default.test;command.
-
-
Optional: Run the
quit;command to exit the Trino CLI.
High-security clusters
-
Log on to the cluster using SSH. For more information, see Log on to a cluster.
-
Run the following command to connect to the Trino CLI.
EMR 3.44.0 or later and EMR 5.10.0 or later
trino --server https://${FQDN}:7778 \ --krb5-config-path /etc/krb5.conf \ --keystore-path /etc/emr/trino-conf/keystore \ --keystore-password ${pwd} \ --krb5-keytab-path /etc/emr/trino-conf/trino.keytab \ --krb5-principal trino/${FQDN}@${REALM} \ --krb5-remote-service-name trino \ --user trino/${FQDN} --catalog ${CATALOG}Versions earlier than EMR 3.44.0 and EMR 5.10.0
NoteFor EMR 3.44.0 or later and EMR 5.10.0 or later, the console displays the service as Trino. For versions earlier than EMR 3.44.0 and EMR 5.10.0, the console displays the service as Presto.
presto --server https://${FQDN}:7778 \ --krb5-config-path /etc/krb5.conf \ --keystore-path /etc/emr/trino-conf/keystore \ --keystore-password ${pwd} \ --krb5-keytab-path /etc/emr/trino-conf/trino.keytab \ --krb5-principal trino/${FQDN}@${REALM} \ --krb5-remote-service-name trino \ --user trino/${FQDN}Parameter
Description
${FQDN}The fully qualified domain name (FQDN) of the master-1-1 node. You can get the FQDN by running the
hostname -fcommand. The format ismaster-1-1.c-xxxxxxx.cn-xxxxxx.emr.aliyuncs.com.--krb5-config-pathThe value of
http.authentication.krb5.configin the config.properties file. The value is/etc/krb5.conf.--keystore-pathThe value of
http-server.https.keystore.pathin the config.properties file. The value is/etc/emr/trino-conf/keystore.--keystore-passwordThe value of
http-server.https.keystore.keyin the config.properties file. This parameter corresponds to ${pwd}. To obtain the value, run theawk -F= '/http-server.https.keystore.key/{print $2}' ${TRINO_CONF_DIR}/config.propertiescommand on the master-1-1 node.--krb5-keytab-pathThe value of
http-server.authentication.krb5.keytabin the config.properties file. The value is/etc/emr/trino-conf/trino.keytab.${REALM}The Kerberos realm, which you can find in the
http-server.authentication.krb5.user-mapping.patternproperty of the config.properties file. In EMR, the realm format isEMR.C-XXXXXX.COM.--krb5-remote-service-nameThe value of
http-server.authentication.krb5.service-namein the config.properties file. The value istrino.${CATALOG}The name of the data source to connect to. For example, specify
--catalog hiveto connect to a Hive data source. -
Run the following command to view the schemas in the current catalog.
show schemas; -
Optional: Run the
quit;command to exit the Trino CLI.
Legacy datalake clusters (Hadoop)
Related documentation
For complex data queries, analysis, and processing, or to integrate query results into a Java application, connect to Trino using JDBC. For more information, see Connect to Trino by using JDBC.