All Products
Search
Document Center

Object Storage Service:Use Presto on an EMR cluster to query data stored in OSS-HDFS

Last Updated:Sep 28, 2023

This topic describes how to use Presto on an E-MapReduce (EMR) cluster to query data stored in OSS-HDFS.

Prerequisites

  • A cluster of EMR V3.42.0 or later, or EMR V5.8.0 or later is created, with the Presto service selected. For more information, see Create a cluster.

  • OSS-HDFS is enabled for a bucket and access permissions on OSS-HDFS are granted. For more information about how to enable OSS-HDFS, see Enable OSS-HDFS and grant access permissions.

Procedure

  1. Log on to the EMR cluster.

    1. Log on to the EMR console. In the left-side navigation pane, click EMR on ECS.

    2. Click the EMR cluster that you created.

    3. Click the Nodes tab, and then click p480359.jpg on the left side of the node group.

    4. Click the ID of the ECS instance. On the Instances page, click Connect next to the instance ID.

    For more information about how to log on to a cluster in Windows or Linux by using an SSH key pair or SSH password, see Log on to a cluster.

  2. Query data stored in OSS-HDFS.

    1. Log on to the Presto server.

      Use the following steps to obtain the address and port of the Presto server: Go to EMR on ECS page, click the name of the cluster, and click Services > Presto > Configure.

      presto --server <presto_server_address>:<presto_server_port> --catalog
    2. Create a schema for OSS.
      create schema testDB with (location='oss://<Bucket>.<Endpoint>/<schema_dir>');
    3. Use the schema.
      use testDB;
    4. Create a table.
      create table tbl (key int, val int);
    5. Insert data into the table.
      insert into tbl values (1,666);
    6. Query data in the table.
      select * from tbl;