Installing Presto using Homebrew


Homebrew (package manager) - Wikipedia

It’s easy to install Presto with Homebrew. You should be up and running in less than 5 minutes by following the steps below.

Pre-requisite

Make sure you have Homebrew installed. If not, simply paste the command below in a Mac terminal

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Installation

Dependency to install Presto is only Java 8+ ( homebrew will take care of dependency ). Prestodb version that brew installs is 0.235.1.

brew install presto

Presto gets installed here: /usr/local/Cellar/prestodb/
As part of the install, the following files are created under the /<version>/libexec/etc folder under the install directory:

* node.properties
* jvm.config
* config.properties
* log.properties

It also creates a sample JMX connector under the etc/catalog folder.

Starting/Stopping Presto

By default as part of the brew install, the presto CLI is installed at the following location:

/usr/local/Cellar/presto/<version>/bin

The executables are added to /usr/local/bin path and hence should already be available as part of $PATH.

Starting Presto

To start presto, we can use the helper script as follows:

$ presto-server start

This starts the service in the background. To start the service in the foreground, you can run:

$ presto-server run

Stopping Presto

To stop, when running in foreground, close the terminal or Ctrl + C. When running in background, use the presto-server helper script as follows:

$ presto-server stop

Accessing the Web UI:

After starting presto server, you can access the web UI using the following link:

http://localhost:8080

Presto CLI

The Presto CLI provides a terminal-based interactive shell for running queries. The CLI is a self-executing JAR file, which means it acts like a normal UNIX executable.

Go to ‘/usr/local/Cellar/prestodb/0.235.1_1/libexec’ and you will find this self-executing jar already present.

Rename it to presto, make it executable with chmod +x, then run it:

$ mv presto-cli-0.235.1-executable.jar presto
./presto --server localhost:8080 --catalog $name --schema default

Run the CLI with the --help option to see the available options.

Let’s create MySQL catalog and connect to our MySQL database

  1. Create catalog file mysql.properties

Note: I have MySQL running locally on my system, but you can change the connection-url to point your MySQL

2. Now let’s connect to this via presto

Note: In presto, terminology schema is equivalent to MySQL DB name