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.
Limits
You cannot enable Ranger authentication and Kerberos authentication for a cluster at the same time.
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:9090In a minor version earlier than EMR V3.44.0 or EMR V5.10.0
presto --server master-1-1:9090Execute 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
testtable 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} --catalog ${CATALOG}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.comformat. You can run thehostname -fcommand to obtain the FQDN.--krb5-config-pathThe value of the
http.authentication.krb5.configparameter in the config.properties file. The value is fixed as/etc/krb5.conf.--keystore-pathThe value of the
http-server.https.keystore.pathparameter in the config.properties file. The value is fixed as/etc/emr/trino-conf/keystore.--keystore-passwordThe value of the
http-server.https.keystore.keyparameter 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.propertiescommand on the master-1-1 node to obtain the value.--krb5-keytab-pathThe value of the
http-server.authentication.krb5.keytabparameter 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.patternparameter in the config.properties file. You need to obtain the value on your own. The Kerberos realm is in theEMR.C-XXXXXX.COMformat.--krb5-remote-service-nameThe value of the
http-server.authentication.krb5.service-nameparameter in the config.properties file. The value is fixed astrino.${CATALOG}The name of the data source to which you want to connect. For example,
--catalog hiveindicates the Hive data source.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.