Hands-On Presto Tutorial: Presto 102

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. 

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.

 

 

 

 

Top