This topic describes how to use a command-line interface (CLI) to access the Presto console.

Prerequisites

An E-MapReduce (EMR) Hadoop cluster is created, and Presto is selected from the optional services during the cluster creation. For more information, see Create a cluster.

Background information

  • If you do not turn on Kerberos Mode during the cluster creation, you can perform operations in Common cluster to access the Presto console.
  • If you have turned on Kerberos Mode during the cluster creation, you can perform operations in High-security cluster to access the Presto console.

Common cluster

  1. Connect to the master node of your cluster in SSH mode.
  2. Run the following command to access the Presto console:
    presto --server emr-header-1:9090 --catalog hive --schema default --user hadoop

    You can run the presto --help command to obtain the help information of the Presto console.

  3. Run the following command to view the schemas contained in the existing catalog:
    show schemas;
    The following information is returned:
           Schema
    --------------------
     default
     emr_presto_init__
     information_schema
    (3 rows)
  4. Optional: Run the quit; command to log off from the Presto console.

High-security cluster

  1. Connect to the master node of your cluster in SSH mode.
  2. Add a principal and export the keytab file.
    1. Run the following command to enable the Kerberos administration tool:
      • EMR V3.30.0 or later V3.X.X, and EMR V4.5.1 or later V4.X.X:
        sh /usr/lib/has-current/bin/admin-local.sh /etc/ecm/has-conf -k /etc/ecm/has-conf/admin.keytab
      • EMR V3.X.X earlier than V3.30.0, and EMR V4.X.X earlier than V4.5.1:
        sh /usr/lib/has-current/bin/hadmin-local.sh /etc/ecm/has-conf -k /etc/ecm/has-conf/admin.keytab
    2. Run the following command to add the principal of a specific key:
      addprinc -randkey test
      Note In this example, the principal of test is added.
    3. Run the following command to export the keytab file:
      xst -k /root/test.keytab test

      By default, the keytab file is exported to the /root/ directory.

  3. Run the following command to access the Presto console:
    presto --server https://<hostname>:7778 \
           --catalog hive \
           --schema default \
           --keystore-path /etc/ecm/presto-conf/keystore \
           --keystore-password <passwd> \
           --krb5-keytab-path <keytab_file> \
           --krb5-principal <username>@EMR.<cluster_id>.COM \
           --krb5-remote-service-name presto \
           --user <username>
    Parameter Description
    hostname The hostname. You can run the hostname command on the emr-header-1 node of your cluster to obtain the hostname. The hostname is in the emr-header-1.cluster-xxx format.
    passwd The password. You can run the sed -n 's/http-server.https.keystore.key=\([^;]*\)/\1/p' /etc/ecm/presto-conf/config.properties command on the emr-header-1 node of your cluster to obtain the password.
    keytab_file The path of the exported keytab file. In this example, the path is /root/test.keytab.
    username The principal of the created keytab file. In this example, the principal is test.
    cluster_id The cluster ID. You can run the hostname | grep -Eo '[0-9]+$' command on the emr-header-1 node of your cluster to obtain the cluster ID.
    The following figure shows the example. Presto
  4. Run the following command to view the schemas contained in the existing catalog:
    show schemas;
    The following information is returned:
           Schema
    --------------------
     default
     emr_presto_init__
     information_schema
    (3 rows)
  5. Optional: Run the quit; command to log off from the Presto console.

FAQ

Q: What do I do if the error message "Access Denied: User xxx@EMR.xxx.COM cannot impersonate user xxx" appears?

A: In the EMR console, go to the config.properties tab for the Presto service of your cluster and click Custom Configuration in the upper-right corner. In the Add Configuration Item dialog box, set the http-server.authentication.krb5.user-mapping.pattern parameter to (.+)@EMR\\.[0-9]+\\.COM. Then, restart PrestoMaster. add parameterThe following figure shows how to restart PrestoMaster. restart