All Products
Search
Document Center

Object Storage Service:Use JindoSDK with Impala to query data stored in OSS-HDFS

Last Updated:Apr 12, 2024

JindoSDK is a simple and easy-to-use Object Storage Service (OSS) client that is developed for the Hadoop and Spark ecosystems. JindoSDK implements a highly optimized Hadoop file system based on OSS. You can use JindoSDK with Impala to query data stored in OSS-HDFS (JindoFS) with better query performance than Hadoop OSS clients.

Prerequisites

Procedure

  1. Connect to the ECS instance. For more information, see Connect to an instance.

  2. Configure JindoSDK.

    1. Download the latest version of the JindoSDK JAR package. For more information, visit GitHub.

    2. Decompress the JindoSDK JAR package.

      The following sample code provides an example on how to decompress a package named jindosdk-x.x.x-linux.tar.gz. If you use another version of JindoSDK, replace the package name with the name of the corresponding JAR package.

      tar zxvf jindosdk-x.x.x-linux.tar.gz
      Note

      x.x.x indicates the version number of the JindoSDK JAR package.

    3. Optional: If Kerberos-related and SASL-related dependencies are not included in your environment, install the following dependencies on all nodes on which JindoSDK is deployed.

      • Ubuntu or Debian

        sudo apt-get install libkrb5-dev krb5-admin-server krb5-kdc krb5-user libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit
      • Red Hat Enterprise Linux or CentOS

        sudo yum install krb5-server krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-plain
      • macOS

        brew install krb5
    4. Copy the downloaded JindoSDK JAR package to the path specified by classpath.

      cp jindosdk-x.x.x-linux/lib/*.jar  $HIVE_HOME/lib/
  3. Configure the implementation class of OSS-HDFS and specify the AccessKey pair that you want to use to access the bucket.

    1. Configure the implementation class of OSS-HDFS in the core-site.xml file of Impala.

      <configuration>
          <property>
              <name>fs.AbstractFileSystem.oss.impl</name>
              <value>com.aliyun.jindodata.oss.JindoOSS</value>
          </property>
      
          <property>
              <name>fs.oss.impl</name>
              <value>com.aliyun.jindodata.oss.JindoOssFileSystem</value>
          </property>
      </configuration>
    2. In the core-site.xml file of Impala, specify the AccessKey ID and AccessKey secret that you want to use to access the bucket for which OSS-HDFS is enabled.

      <configuration>
          <property>
              <name>fs.oss.accessKeyId</name>
              <value>LTAI5t7h6SgiLSganP2m****</value>
          </property>
      
          <property>
              <name>fs.oss.accessKeySecret</name>
              <value>KZo149BD9GLPNiDIEmdQ7d****</value>
          </property>
      </configuration>
  4. Configure the endpoint of OSS-HDFS.

    You must specify the endpoint of OSS-HDFS if you want to use OSS-HDFS to access buckets in Object Storage Service (OSS). We recommend that you configure the path that is used to access OSS-HDFS in the oss://<Bucket>.<Endpoint>/<Object> format. Example: oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/exampleobject.txt. After you configure the access path, JindoSDK calls the corresponding OSS-HDFS operation based on the specified endpoint in the access path.

    You can also configure the endpoint of OSS-HDFS by using other methods. The endpoints that are configured by using different methods have different priorities. For more information, see Appendix 1: Other methods used to configure the endpoint of OSS-HDFS.

  5. Use Impala to query data stored in OSS-HDFS.

    1. Create a table.

      CREATE EXTERNAL TABLE customer_demographics (
       `cd_demo_sk` INT,
       `cd_gender` STRING,
       `cd_marital_status` STRING,
       `cd_education_status` STRING,
       `cd_purchase_estimate` INT,
       `cd_credit_rating` STRING,
       `cd_dep_count` INT,
       `cd_dep_employed_count` INT,
       `cd_dep_college_count` INT)
      STORED AS PARQUET
      LOCATION 'oss://bucket.endpoint/dir';
    2. Query data in the table.

      select * from customer_demographics;