This topic describes how to run commands to access the Presto console.

Prerequisites

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

Usage notes

Data lake clusters do not support the Kerberos Authentication feature.

Common cluster

Note If you do not turn on Kerberos Authentication when you create a cluster, the cluster is a common cluster.
  1. Log on to the Hadoop cluster or Presto cluster in SSH mode. For more information, see Log on to a cluster.
  2. Run the following command to go to the Presto console:
    • Data lake cluster
      presto --server master-1-1:9090 --catalog hive --schema default --user hadoop
    • Hadoop cluster
      presto --server emr-header-1:9090 --catalog hive --schema default --user hadoop

    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 output 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

Note If you turn on Kerberos Authentication when you create a cluster, the cluster is a high-security cluster. Data lake clusters do not support the Kerberos Authentication feature.
  1. Log on to the Hadoop cluster or Presto cluster in SSH mode. For more information, see Log on to a cluster.
  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;
  5. Optional: Run the quit; command to log off from the Presto console.

FAQ

Q: What do I do if the "Access Denied: User xxx@EMR.xxx.COM cannot impersonate user xxx" error message is displayed when I access the Presto console?

A: You need to add a parameter on the config.properties tab of the Presto service in the EMR console. Set the value of the http-server.authentication.krb5.user-mapping.pattern parameter to (.+)@EMR\\.[0-9]+ \. COM and then restart the service. presto