Help Center > > User Guide> MRS Cluster Component Operation Guide> Using Presto> Using a Client to Execute Query Statements

Using a Client to Execute Query Statements

Updated at: Mar 31, 2020 GMT+08:00

You can perform an interactive query on an MRS cluster client. For clusters with Kerberos authentication enabled, users who submit topologies must belong to the presto group.

Prerequisites

  • The password of user admin has been obtained. The password of user admin is specified by you during MRS cluster creation.
  • The client has been updated.

Procedure

  1. In a cluster with Kerberos authentication enabled, log in to MRS Manager and create a role with the Hive Admin Privilege permissions. For details about how to create a role, see Creating a Role.
  2. Create a user that belongs to the Presto and Hive groups, bind the role created in 1 to the user, and download the user authentication files. For details, see Creating a User and Downloading a User Authentication File.
  3. Upload the downloaded user.keytab and krb5.conf files to the node where the MRS client resides.

    For clusters with Kerberos authentication enabled, 2 and 3 must be performed. For normal clusters, start from 4.

  4. Log in to the node where the client is installed.

    For example, if you have updated the client on the Master2 node, log in to the Master2 node to use the client. For details, see Updating a Client.

  5. Run the following command to switch the user:

    sudo su - omm

  6. Run the following command to switch to the client directory, for example, /opt/client.

    cd /opt/client

  7. Run the following command to configure environment variables:

    source bigdata_env

  8. Connect to the Presto Server. The following provides two client connection methods based on the client type.

    • Using the client provided by MRS
      • For clusters with Kerberos authentication disabled, run the following command to connect to the Presto Server of the cluster:

        presto_cli.sh

      • For clusters with Kerberos authentication disabled, run the following command to connect to the Presto Server of other clusters. In the command, ip indicates the Presto Server IP address of the cluster, and port indicates the Presto Server port number. The default port is 7520.

        presto_cli.sh --server http://ip:port

      • For clusters with Kerberos authentication enabled, run the following command to connect to the Presto Server of the cluster:

        presto_cli.sh --krb5-config-path krb5.conf file path --krb5-principal User's principal --krb5-keytab-path user.keytab file path --user presto username

      • For clusters with Kerberos authentication enabled, run the following command to connect to the Presto Server of other clusters. In the command, ip indicates the Presto Server IP address of the cluster, and port indicates the Presto Server port number. The default port is 7521.

        presto_cli.sh --krb5-config-path krb5.conf file path --krb5-principal User's principal --krb5-keytab-path user.keytab file path --server https://ip:port --krb5-remote-service-name Presto Server name

    • Using the native client

      The native client of Presto is Presto/presto/bin/presto in the client directory. For details about how to use the client, see https://prestodb.io/docs/0.215/installation/cli.html and https://prestodb.io/docs/0.215/security/cli.html.

  9. Run a query statement, for example, show catalogs. For more statements, see https://prestodb.io/docs/0.215/sql.html.

    For clusters with Kerberos authentication enabled, when querying Hive Catalog data, the user who runs the Presto client must have the permission to access Hive tables and run the grant all on table [table_name] to group hive command in Hive beeline to grant permissions to the Hive group.

  10. After the query is complete, run the following command to exit the client:

    quit

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel