Hands-on Presto Tutorial: Presto 102

Running a three node PrestoDB cluster on a laptop


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.

C:\Users\rupendran>docker network create presto_networkd0d03171c01b5b0508a37d968ba25638e6b44ed4db36c1eff25ce31dc435415b

Step 2: 

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.

C:\Users\prestodb>docker pull ahanaio/prestodb-sandboxUsing default tag: latestlatest: Pulling from ahanaio/prestodb-sandboxda5a05f6fddb: Pull complete                                                                                             e8f8aa933633: Pull complete                                                                                             b7cf38297b9f: Pull complete                                                                                             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 the prestodb sandbox and name it as coordinator.

C:\Users\prestodb>docker run -d -p 8080:8080 -it --net presto_network --name coordinator ahanaio/prestodb-sandboxdb74c6f7c4dda975f65226557ba485b1e75396d527a7b6da9db15f0897e6d47f

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.

sh-4.2# cat etc/config.propertiescoordinator=truenode-scheduler.include-coordinator=falsehttp-server.http.port=8080discovery-server.enabled=truediscovery.uri=http://localhost:8080sh-4.2#

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

Step 5: 

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

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

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.

sh-4.2# cat etc/config.propertiescoordinator=falsehttp-server.http.port=8081discovery.uri=http://coordinator:8080sh-4.2#

Step 7:

Restart the worker1 container check prestodb UI, now the active worker count will be set to either 1 if co-ordinator 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
C:\Users\rupendran>docker run -d -p 8082:8082 -it --net presto_network --name workerN2 ahanaio/prestodb-sandbox16eb71da54d4a9c30947970ff6da58c65bdfea9cb6ad0c76424d527720378bdd
sh-4.2# cat etc/config.propertiescoordinator=falsehttp-server.http.port=8082discovery.uri=http://coordinator:8080

Step 9: 

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

Step 10:

Verify the prestodb environment by running the prestodb CLI with simple tpch query

sh-4.2# presto-cli
presto> SHOW SCHEMAS FROM tpch;
(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]



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