Alluxio
ProductsLanguageHome
  • Introduction
  • Overview
    • Architecture
    • Job Service
    • Quick Start Guide
    • FAQ
    • Use Cases
  • Core Services
    • Caching
    • Unified Namespace
  • Install Alluxio
    • Local Machine
    • Cluster
    • Cluster with HA
    • Docker
    • Software Requirements
  • Kubernetes
    • Deploy
    • Spark on Kubernetes
    • Metrics
  • Cloud Native
    • Alibaba Cloud ACK
    • AWS EMR
    • Tencent EMR
    • Google Dataproc
  • Compute Integration
    • Apache Spark
    • Apache Hadoop MapReduce
    • Apache Flink
    • Apache Hive
    • Presto on Iceberg (Experimental)
    • Presto
    • Trino
    • Tensorflow
  • Storage Integrations
    • Amazon AWS S3
    • HDFS
    • Azure Blob Store
    • Azure Data Lake Storage Gen2
    • Azure Data Lake Storage
    • Google Cloud Storage
    • Qiniu Kodo
    • COSN
    • CephObjectStorage
    • MinIO
    • NFS
    • Aliyun Object Storage Service
    • Ozone
    • Swift
    • WEB
    • CephFS
  • Security
  • Operations
    • Configuration Settings
    • User CLI
    • Admin CLI
    • Web UI
    • Journal Management
    • Metastore Management
    • Metrics
  • Administration
    • Troubleshooting
    • Basic Logging
    • Remote Logging
    • Performance Tuning
    • Scalability Tuning
    • StressBench (Experimental)
    • Upgrading
  • Solutions
  • Client APIs
    • Java API
    • S3 API
    • REST API
    • POSIX API
  • Contributor Resources
    • Building Alluxio From Source
    • Contribution Guide
    • Code Conventions
    • Documentation Conventions
    • Contributor Tools
  • Reference
    • List Of Configuration Properties
    • List of Metrics
  • REST API
    • Master REST API
    • Worker REST API
    • Proxy REST API
    • Job REST API
  • Javadoc
Powered by GitBook
On this page
  • Prerequisites
  • Basic Setup
  • Configure Trino to connect to Hive Metastore
  • Distribute the Alluxio client jar to all Trino servers
  • Examples: Use Trino to Query Tables on Alluxio
  • Create a Hive table on Alluxio
  • Start Hive Metastore
  • Start Trino server
  • Query tables using Trino
  • Advanced Setup
  • Customize Alluxio User Properties
  • Increase parallelism
  • Avoid Trino timeouts when reading large files
  1. Compute Integration

Trino

Last updated 6 months ago

is an open source distributed SQL query engine for running interactive analytic queries on data at a large scale. This guide describes how to run queries against Trino with Alluxio as a distributed caching layer, for any data storage systems that Alluxio supports (AWS S3, HDFS, Azure Blob Store, NFS, and more). Alluxio allows Trino to access data regardless of the data source and transparently cache frequently accessed data (e.g., tables commonly used) into Alluxio distributed storage. Co-locating Alluxio workers with Trino workers improves data locality and reduces the I/O access latency when other storage systems are remote or the network is slow or congested.

Prerequisites

  • Setup Java for Java 11, at least version 11.0.7, 64-bit,as required by Trino

  • Setup Python version 2.6.x, 2.7.x, or 3.x, as required by Trino

  • . This guide is tested with Trino-352.

  • Alluxio has been set up and is running.

  • Make sure that the Alluxio client jar is available. This Alluxio client jar file can be found at {{site.ALLUXIO_CLIENT_JAR_PATH}} in the tarball downloaded from Alluxio .

  • Make sure that Hive Metastore is running to serve metadata information of Hive tables.

Basic Setup

Configure Trino to connect to Hive Metastore

Trino gets the database and table metadata information (including file system locations) from the Hive Metastore, via Trino's Hive connector. Here is a example Trino configuration file ${Trino_HOME}/etc/catalog/hive.properties, for a catalog using the Hive connector, where the metastore is located on localhost.

connector.name=hive-hadoop2
hive.metastore.uri=thrift://localhost:9083

Distribute the Alluxio client jar to all Trino servers

In order for Trino to be able to communicate with the Alluxio servers, the Alluxio client jar must be in the classpath of Trino servers. Put the Alluxio client jar {{site.ALLUXIO_CLIENT_JAR_PATH}} into the directory ${Trino_HOME}/plugin/hive-hadoop2/ (this directory may differ across versions) on all Trino servers. Restart the Trino workers and coordinator:

$ ${Trino_HOME}/bin/launcher restart

Examples: Use Trino to Query Tables on Alluxio

Create a Hive table on Alluxio

$ ./bin/alluxio fs mkdir /ml-100k
$ ./bin/alluxio fs copyFromLocal /path/to/ml-100k/u.user alluxio:///ml-100k

Create an external Hive table pointing to the Alluxio file location.

hive> CREATE TABLE u_user (
  userid INT,
  age INT,
  gender CHAR(1),
  occupation STRING,
  zipcode STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
STORED AS TEXTFILE
LOCATION 'alluxio://master_hostname:port/ml-100k';

You can see the directory and files that Hive creates by viewing the Alluxio WebUI at http://master_hostname:19999

Start Hive Metastore

Ensure your Hive Metastore service is running. Hive Metastore listens on port 9083 by default. If it is not running, execute the following command to start the metastore:

$ ${HIVE_HOME}/bin/hive --service metastore

Start Trino server

Start your Trino server. Trino server runs on port 8080 by default (configurable with http-server.http.port in ${Trino_HOME}/etc/config.properties ):

$ ${Trino_HOME}/bin/launcher run

Query tables using Trino

Run a single query (replace localhost:8080 with your actual Trino server hostname and port):

$ ./trino --server localhost:8080 --execute "use default; select * from u_user limit 10;" \
  --catalog hive --debug

Advanced Setup

Customize Alluxio User Properties

...
-Xbootclasspath/a:<path-to-alluxio-conf>

Alternatively, add Alluxio properties to the Hadoop configuration files (core-site.xml, hdfs-site.xml), and use the Trino property hive.config.resources in the file ${Trino_HOME}/etc/catalog/hive.properties to point to the Hadoop resource locations for every Trino worker.

hive.config.resources=/<PATH_TO_CONF>/core-site.xml,/<PATH_TO_CONF>/hdfs-site.xml

Example: connect to Alluxio with HA

If the Alluxio HA cluster uses internal leader election, set the Alluxio cluster property appropriately in the alluxio-site.properties file which is on the classpath.

alluxio.master.rpc.addresses=master_hostname_1:19998,master_hostname_2:19998,master_hostname_3:19998

Alternatively you can add the property to the Hadoop core-site.xml configuration which is contained by hive.config.resources.

<configuration>
  <property>
    <name>alluxio.master.rpc.addresses</name>
    <value>master_hostname_1:19998,master_hostname_2:19998,master_hostname_3:19998</value>
  </property>
</configuration>

Example: change default Alluxio write type

For example, change alluxio.user.file.writetype.default from default ASYNC_THROUGH to CACHE_THROUGH.

One can specify the property in alluxio-site.properties and distribute this file to the classpath of each Trino node:

alluxio.user.file.writetype.default=CACHE_THROUGH

Alternatively, modify conf/hive-site.xml to include:

<property>
  <name>alluxio.user.file.writetype.default</name>
  <value>CACHE_THROUGH</value>
</property>

Increase parallelism

Trino's Hive connector uses the config hive.max-split-size to control the parallelism of the query. For Alluxio 1.6 or earlier, it is recommended to set this size no less than Alluxio's block size to avoid the read contention within the same block. For later Alluxio versions, this is no longer an issue because of Alluxio's async caching abilities.

Avoid Trino timeouts when reading large files

It is recommended to increase alluxio.user.streaming.data.timeout to a bigger value (e.g 10min) to avoid a timeout failure when reading large files from remote workers.

After completing the basic configuration, Trino should be able to access data in Alluxio. To configure more advanced features for Trino (e.g., connect to Alluxio with HA), please follow the instructions at .

Here is an example to create an internal table in Hive backed by files in Alluxio. You can download a data file (e.g., ml-100k.zip) from . Unzip this file and upload the file u.user into /ml-100k/ in Alluxio:

Follow to download the trino-cli-<Trino_VERSION>-executable.jar, rename it to trino, and make it executable with chmod +x (sometimes the executable trino exists in ${trino_HOME}/bin/trino and you can use it directly).

To configure additional Alluxio properties, you can append the conf path (i.e. ${ALLUXIO_HOME}/conf) containing to Trino's JVM config at etc/jvm.config under Trino folder. The advantage of this approach is to have all the Alluxio properties set within the same file of alluxio-site.properties.

For information about how to connect to Alluxio HA cluster using Zookeeper-based leader election, please refer to .

Trino
Deploy Trino
download page
http://grouplens.org/datasets/movielens/
Trino CLI instructions
alluxio-site.properties
Advanced Setup
HA mode client configuration parameters