DEV Community

Cover image for 🚀 Setting Up Presto : A Step by Step Installation Guide to Run SQL Queries.
Saurabh Mahawar
Saurabh Mahawar

Posted on • Edited on

🚀 Setting Up Presto : A Step by Step Installation Guide to Run SQL Queries.

In previous articles, we explored the fundamentals of Presto as a powerful open-source SQL query engine and the modern data storage paradigms of data warehouses and data lakes. Now it's time to roll up our sleeves and get our hands dirty with a practical implementation.

In this guide, I'll walk you through installing Presto and show how to run queries with ease.

Pre-Requisites

Before getting started, ensure that the following are installed:

  • Operating System: macOS (Intel or Apple Silicon), Linux, or Windows.
  • Java Development Kit (JDK): Java 17 is now required for newer Presto versions. (Java 8 is no longer sufficient). (Run java -version to confirm).
  • Python: Version 2.7 or 3.x (Presto’s launcher uses Python). (Run python3 --version to confirm).
  • RAM: Minimum 4GB available (8GB+ recommended).

Download and Extract

  • Open terminal/command line interface and run below command’s.
# 1. Download the tarball
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-server/0.296/presto-server-0.296.tar.gz

# 2. Extract it
tar -xvzf presto-server-0.296.tar.gz

# 3. Move it to your Desktop or your preferred directory
mv presto-server-0.296 ~/Desktop/presto-server
cd ~/Desktop/presto-server
Enter fullscreen mode Exit fullscreen mode
  • Verify that the resulting directory structure matches the example below: Directory Structure

Configure the Server

  • Inside presto-server–*, create the etc configuration directory.
mkdir etc
Enter fullscreen mode Exit fullscreen mode
  • Create the following four files inside the etc directory: config.properties, jvm.config, log.properties, and node.properties.

Directory Structure - After Configuration

  • Apply the following configurations to the node.properties file. (This identifies your machine).
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=/path-to-your-presto-server/data -----> Set this path to your presto server directory location
Enter fullscreen mode Exit fullscreen mode
  • Apply the following configurations to the jvm.config file. (This tunes the Java engine. Use this exact config to support Java 17).
-server
-Xmx2G
-XX:+UseG1GC
-XX:G1HeapRegionSize=32M
-XX:+UseGCOverheadLimit
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
-Djdk.attach.allowAttachSelf=true
Enter fullscreen mode Exit fullscreen mode
  • Apply the following configurations to the config.properties file. (This sets up your node as both a Coordinator and a Worker).
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
query.max-memory=1.5GB
query.max-memory-per-node=1GB
query.max-total-memory-per-node=1.2GB
discovery-server.enabled=true
discovery.uri=http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

query.max-memory (1.5GB) must be smaller than the JVM Heap (2GB).

  • Apply the following configurations to the log.properties file. (This sets your default logging level).
com.facebook.presto=INFO
Enter fullscreen mode Exit fullscreen mode

Add Data Connectors

  • Create the catalog folder inside etc directory:
mkdir etc/catalog
Enter fullscreen mode Exit fullscreen mode
  • Create a file named etc/catalog/tpch.properties and apply below configuration:
connector.name=tpch
Enter fullscreen mode Exit fullscreen mode

Start the Server

  • Navigate to the presto-server-* directory and run command:
bin/launcher start
Enter fullscreen mode Exit fullscreen mode
  • Wait 10 seconds, then check the status:
bin/launcher status
Enter fullscreen mode Exit fullscreen mode

Verify that Presto Server has started on localhost 8080<br>

Run Your First Query through Presto CLI

  • Download the CLI from here and move the jar file to presto-server-* directory with below command:
mv ~/Downloads/presto-cli-0.296-executable.jar ./presto
Enter fullscreen mode Exit fullscreen mode
  • Make it executable:
chmod +x presto
Enter fullscreen mode Exit fullscreen mode
  • Connect to your local cluster:
./presto --server localhost:8080 --catalog tpch --schema tiny
Enter fullscreen mode Exit fullscreen mode
  • Once you see the presto:tiny> prompt, you can type your SQL:
SHOW TABLES;
Enter fullscreen mode Exit fullscreen mode
  • Run a standard TPC-H aggregation query
SELECT returnflag, linestatus, sum(quantity) as sum_qty, count(*) as count_order FROM lineitem GROUP BY returnflag, linestatus;
Enter fullscreen mode Exit fullscreen mode
  • To stop the server cleanly:
bin/launcher stop
Enter fullscreen mode Exit fullscreen mode

Troubleshooting Common Issues

If the server fails to launch, investigate these three common configuration pitfalls:

  • Port 8080 already in use

The Error: java.net.BindException: Address already in use. Another app (often another web server or Jenkins) is using port 8080.

The Fix: Kill the process using it: lsof -i :8080 then kill -9 . Change Presto’s port in etc/config.properties to 8081.

  • Java version not supported

The Error: Presto requires Java 17+ (found 1.8.0_xxx). You are running an old Java version.

The Fix: Run java -version to check. If you have valid Java 17 installed but it’s not default, point to it explicitly in your startup command: JAVA_HOME=/path/to/java17 bin/launcher start

  • Server Starts but Dies Immediately

The Error: Launcher says “Started” but status says “Not running”. This is usually a configuration typo or memory issue.

The Fix: Check the detailed logs: cat data/var/log/server.log. Ensure query.max-memory in config.properties is less than -Xmx in jvm.config.

In the next article, we will see how to install Apache Zeppelin and connect it with Presto.

Follow Presto at Official Website, Linkedin, Youtube, and Join Slack channel to interact with the community.

Top comments (0)