DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Solving the Mystery: Why Java RSS Grows in Docker on M1 Macs
  • Java Backend Development in the Era of Kubernetes and Docker
  • Java in a Container: Efficient Development and Deployment With Docker
  • Buildpacks: An Open-Source Alternative to Chainguard

Trending

  • Identity in Action
  • Building AI-Powered Java Applications With Jakarta EE and LangChain4j
  • Observability for Agents and Workflows: Tracing Prompts, Tool Calls, and Business Outcomes End-to-End
  • Building a Spring AI Assistant With MCP Servers: A Step-by-Step Tutorial
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Hands-On Presto Tutorial: Presto 102

Hands-On Presto Tutorial: Presto 102

This tutorial will guide you how to run a 3 node Presto cluster on a laptop.

By 
Praburam Upendran user avatar
Praburam Upendran
·
Dipti Borkar user avatar
Dipti Borkar
·
Updated Sep. 23, 21 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
15.6K Views

Join the DZone community and get the full member experience.

Join For Free

This guide was developed using a laptop running Windows OS and docker on it.

Implementation Steps

This guide was developed using a laptop running Windows OS and docker on it.

Step 1: 

Create a docker network namespace, so that containers could communicate with each other using the network namespace.

Java
 
C:\Users\rupendran>docker network create 
presto_networkd0d03171c01b5b0508a37d968ba25638e6b44ed4db36c1eff25ce31dc435415b

Ahana has developed a sandbox for PrestoDB which can be downloaded from docker hub, use the below command to download PrestoDB sandbox, which comes with all packages needed to run PrestoDB.

Java
 
C:\Users\prestodb>docker pull ahanaio/prestodb-sandbox
Using default tag: latestlatest: Pulling
from ahanaio/prestodb-sandboxda5a05f6fddb: Pull complete 
e8f8aa933633: Pull complete
b7cf38297b9f: Pullcomplete
a4205d42b3be: Pull complete
81b659bbad2f: Pull complete
3ef606708339: Pull complete
979857535547: Pull complete                                                                                
Digest: sha256:d7f4f0a34217d52aefad622e97dbcc16ee60ecca7b78f840d87c141ba7137254Status: 
Downloaded newer image for ahanaio/prestodb-sandbox:latestdocker.io/ahanaio/prestodb-sandbox:latest


Step 3:  

Start the instance of the PrestoDB sandbox and name it as coordinator.

Java
 
C:\Users\prestodb>docker run -d -p 8080:8080 -it --net presto_network --name coordinator ahanaio/prestodb-sandboxdb
74c6f7c4dda975f65226557ba485b1e75396d527a7b6da9db15f0897e6d47f


Step 4: 

Check cluster UI on the status, by default the Ahana PrestoDB sandbox comes with one worker and a coordinator.


If only the coordinator needs to be running without the worker node then edit the config.properties file and set the node-scheduler.include-cooridinator to false.

Java
 
sh-4.2# cat etc/config.properties
coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=8080
discovery-server.enabled=true
discovery.uri=http://localhost:8080
sh-4.2#


Now the PrestoDB UI will show the Active worker count to 0.


Step 5: 

Start another instance of PrestoDB sandbox which will run as worker node

Java
 
C:\Users\rupendran>docker run -d -p 8081:8081 -it --net presto_network --name workerN1 ahanaio/prestodb-sandbox
80dbb7e1d170434e06c10f9316983291c10006d53d9c6fc8dd20db60ddb4a58c


Step 6: 

Since sandbox comes with coordinator it needs to be disabled for the second instance and run it as worker node, to do that click on the terminal window on the docker container/apps UI  and edit etc/config.properties file to set coordinator to false and set http port to be different from coordinator.

Java
 
sh-4.2# cat etc/config.properties
coordinator=false
http-server.http.port=8081
discovery.uri=http://coordinator:8080
sh-4.2#


Step 7:

Restart the worker1 container check PrestoDB UI, now the active worker count will be set to either 1 if coordinator runs without a worker node or 2 if the coordinator also runs a worker node.


Step 8: 

Repeat steps 5 to 7 to add a third worker node. 

  • Start new instance of Ahanaio/PrestoDB sandbox
  • Disable coordinator and set port to be different than coordinator and set URI to the container name of the coordinator
Java
 
C:\Users\rupendran>docker run -d -p 8082:8082 -it --net presto_network --name workerN2 ahanaio/prestodb-sandbox
16eb71da54d4a9c30947970ff6da58c65bdfea9cb6ad0c76424d527720378bdd


Step 9: 

Check cluster status, which should reflect the third worker node as part of the PrestoDB cluster.


Step 10:

Verify the PrestoDB environment by running the PrestoDB CLI with a simple tpch query

Java
 
sh-4.2# presto-cli
presto> SHOW SCHEMAS FROM tpch;
Schema
-----------------
information_schema
sf1
sf100
sf1000
sf10000
sf100000
sf300
sf3000
sf30000
tiny
(10 rows)

Query 20210709_195712_00006_sip3d, FINISHED, 3 nodes
Splits: 36 total, 36 done (100.00%)
0.01 [10 rows, 119B] [12 row/s, 153B/s]

presto>


Summary

PrestoDB cluster installation is simplified with Ahana PrestoDB sandbox. It’s now ready to be used for any functional validation.

Docker (software) Presto (SQL query engine) Sandbox (software development) Java (programming language)

Published at DZone with permission of Praburam Upendran. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Solving the Mystery: Why Java RSS Grows in Docker on M1 Macs
  • Java Backend Development in the Era of Kubernetes and Docker
  • Java in a Container: Efficient Development and Deployment With Docker
  • Buildpacks: An Open-Source Alternative to Chainguard

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook