After you create a cluster that contains the Trino service, you can use the CLI to connect to Trino and query data in a simple and fast manner.
Prerequisites
An E-MapReduce (EMR) cluster that contains the Trino service is created. For more information about how to create a cluster, see Create a cluster.
DataLake clusters and custom clusters
If you turn on Kerberos Authentication when you create a cluster, the cluster is a high-security cluster. Otherwise, the cluster is a common cluster.
Common clusters
Log on to your cluster in SSH mode. For more information, see Log on to a cluster.
Run the following command to connect to the Trino CLI:
NoteIf your cluster is of EMR V3.44.0 or a later minor version, or of EMR V5.10.0 or a later minor version, the service name is Trino. If your cluster is of a minor version earlier than EMR V3.44.0 or EMR V5.10.0, the service name is Presto.
In EMR V3.44.0, EMR V5.10.0, or a minor version later than EMR V3.44.0 or EMR V5.10.0
trino --server master-1-1:9090
In a minor version earlier than EMR V3.44.0 or EMR V5.10.0
presto --server master-1-1:9090
Execute the following statement to view the table data:
select * from <catalog>.<schema>.<table>;
Parameters in the preceding statement:
<catalog>
: specifies the name of the data source that you want to connect to.<schema>
specifies the name of the database that you want to use.<table>
specifies the name of the table from which you want to query data.For example, if you want to query data from the
test
table in the default database of Hive, you can execute theselect * from hive.default.test;
statement.
Optional. Run the
quit;
command to exit the Trino CLI.
High-security clusters
Log on to your cluster in SSH mode. For more information, see Log on to a cluster.
Run the following command to connect to the Trino CLI:
In EMR V3.44.0, EMR V5.10.0, or a minor version later than EMR V3.44.0 or EMR V5.10.0
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}
In a minor version earlier than EMR V3.44.0 or EMR V5.10.0
NoteIf your cluster is of EMR V3.44.0 or a later minor version, or of EMR V5.10.0 or a later minor version, the service name is Trino. If your cluster is of a minor version earlier than EMR V3.44.0 or EMR V5.10.0, the service name is 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. The FQDN must be in the
master-1-1.c-xxxxxxx.cn-xxxxxx.emr.aliyuncs.com
format. You can run thehostname -f
command to obtain the FQDN.--krb5-config-path
The value of the
http.authentication.krb5.config
parameter in the config.properties file. The value is fixed as/etc/krb5.conf
.--keystore-path
The value of the
http-server.https.keystore.path
parameter in the config.properties file. The value is fixed as/etc/emr/trino-conf/keystore
.--keystore-password
The value of the
http-server.https.keystore.key
parameter in the config.properties file. In this example, the value is ${pwd}. You can run theawk -F= '/http-server.https.keystore.key/{print $2}' ${TRINO_CONF_DIR}/config.properties
command on the master-1-1 node to obtain the value.--krb5-keytab-path
The value of the
http-server.authentication.krb5.keytab
parameter in the config.properties file. The value is fixed as/etc/emr/trino-conf/trino.keytab
.${REALM}
The value of the
http-server.authentication.krb5.user-mapping.pattern
parameter in the config.properties file. You need to obtain the value on your own. The Kerberos realm is in theEMR.C-XXXXXX.COM
format.--krb5-remote-service-name
The value of the
http-server.authentication.krb5.service-name
parameter in the config.properties file. The value is fixed astrino
.Run the following command to view the schemas contained in the existing catalog:
show schemas;
Optional. Run the
quit;
command to exit the Trino CLI.
Hadoop clusters
References
You can use JDBC to connect to Trino to query, analyze, and process complex data, or integrate query results into Java applications. For more information, see Use JDBC.