After you create a cluster that contains the Presto service, you can use the CLI to connect to Presto and run simple and fast data queries.
Prerequisites
Create an E-MapReduce (EMR) cluster of version EMR-3.45.0 or later, or EMR-5.11.0 or later, with the Presto service selected. For more information, see Create a cluster.
Standard cluster
If you did not enable Kerberos Authentication when you created the cluster, the cluster is a standard cluster.
-
Log on to the cluster using SSH. For more information, see Log on to a cluster.
-
Run the following command to enter the Presto CLI.
presto --server master-1-1:8889 -
Run the following command to query table data.
select * from <catalog>.<schema>.<table>;The parameters in the command are described as follows:
-
<catalog>: The name of the data source.You can run the
show catalogs;command to view all catalogs. Alternatively, go to the Configure tab of the Presto service in the EMR console to view all catalogs. -
<schema>: The name of the database to query. -
<table>: The table to query.For example, to view the data in the
testtable of the default database in a Hive data source, run theselect * from hive.default.test;command.
-
-
Optional: Run
quit;to exit the Presto CLI.
High-security cluster
If you enabled Kerberos Authentication when you created the cluster, the cluster is a high-security cluster.
-
Log on to the cluster using SSH. For more information, see Log on to a cluster.
-
Run the following command to enter the Presto CLI.
presto --server https://${FQDN}:7779 \ --krb5-config-path /etc/krb5.conf \ --keystore-path /etc/emr/presto-conf/keystore \ --keystore-password ${pwd} \ --krb5-keytab-path /etc/emr/presto-conf/presto.keytab \ --krb5-principal presto/${FQDN}@${REALM} \ --krb5-remote-service-name presto \ --user presto/${FQDN}ImportantAfter high security is enabled, you can access Presto only over HTTPS. HTTP port 8889 is closed, and the UI is no longer accessible via HTTP. The value of http-server.http.port is overridden by http-server.https.port. The HTTPS port is 7779.
Parameter
Description
${FQDN}
The fully qualified domain name (FQDN) of the master-1-1 node. You can run the
hostname -fcommand to obtain the FQDN. The FQDN is in themaster-1-1.c-xxxxxxx.cn-xxxxxx.emr.aliyuncs.comformat.--krb5-config-path
Corresponds to the
http.authentication.krb5.configsetting in theconfig.propertiesfile. This value is fixed to/etc/krb5.conf.--keystore-path
Corresponds to the
http-server.https.keystore.pathsetting in theconfig.propertiesfile. This value is fixed to/etc/emr/presto-conf/keystore.--keystore-password
The value of
http-server.https.keystore.keyin theconfig.propertiesfile, which is used for the ${pwd} parameter. You can run theawk -F= '/http-server.https.keystore.key/{print $2}' ${PRESTO_CONF_DIR}/config.propertiescommand on the master-1-1 node to obtain the value.--krb5-keytab-path
Corresponds to the
http-server.authentication.krb5.keytabsetting in theconfig.propertiesfile. This value is fixed to/etc/emr/presto-conf/presto.keytab.${REALM}
The Kerberos REALM. Unlike Trino, the Presto REALM is specified in the
/etc/krb5.conffile instead of a service configuration file. The REALM for Kerberos within EMR uses theEMR.C-XXXXXX.COMformat.--krb5-remote-service-name
Corresponds to the
http.server.authentication.krb5.service-namesetting in theconfig.propertiesfile. This value is fixed topresto. -
Run the following command to query table data.
select * from <catalog>.<schema>.<table>;The parameters in the command are described as follows:
-
<catalog>: The name of the data source.You can run the
show catalogs;command to view all catalogs. Alternatively, go to the Configure tab of the Presto service in the EMR console to view all catalogs. -
<schema>: The name of the database to query. -
<table>: The table to query.For example, to view the data in the
testtable of the default database in a Hive data source, run theselect * from hive.default.test;command.
-
-
Optional: Run
quit;to exit the Presto CLI.
Related documentation
For complex data queries, analysis, processing, or integrating query results into Java applications, use JDBC to connect to Presto. For more information, see Connect to Presto using JDBC.