All Products
Search
Document Center

E-MapReduce:Connect to Presto using the CLI

Last Updated:Aug 20, 2026

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

Note

If you did not enable Kerberos Authentication when you created the cluster, the cluster is a standard cluster.

  1. Log on to the cluster using SSH. For more information, see Log on to a cluster.

  2. Run the following command to enter the Presto CLI.

    presto --server master-1-1:8889
  3. 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 test table of the default database in a Hive data source, run the select * from hive.default.test; command.

  4. Optional: Run quit; to exit the Presto CLI.

High-security cluster

Note

If you enabled Kerberos Authentication when you created the cluster, the cluster is a high-security cluster.

  1. Log on to the cluster using SSH. For more information, see Log on to a cluster.

  2. 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}
    Important

    After 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 -f command to obtain the FQDN. The FQDN is in the master-1-1.c-xxxxxxx.cn-xxxxxx.emr.aliyuncs.com format.

    --krb5-config-path

    Corresponds to the http.authentication.krb5.config setting in the config.properties file. This value is fixed to /etc/krb5.conf.

    --keystore-path

    Corresponds to the http-server.https.keystore.path setting in the config.properties file. This value is fixed to /etc/emr/presto-conf/keystore.

    --keystore-password

    The value of http-server.https.keystore.key in the config.properties file, which is used for the ${pwd} parameter. You can run the awk -F= '/http-server.https.keystore.key/{print $2}' ${PRESTO_CONF_DIR}/config.properties command on the master-1-1 node to obtain the value.

    --krb5-keytab-path

    Corresponds to the http-server.authentication.krb5.keytab setting in the config.properties file. 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.conf file instead of a service configuration file. The REALM for Kerberos within EMR uses the EMR.C-XXXXXX.COM format.

    --krb5-remote-service-name

    Corresponds to the http.server.authentication.krb5.service-name setting in the config.properties file. This value is fixed to presto.

  3. 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 test table of the default database in a Hive data source, run the select * from hive.default.test; command.

  4. 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.