---
title: "Install the Trino Connector"
slug: "/trino-connector/installation"
keyword: "gravitino connector trino"
license: "This software is licensed under the Apache License version 2."
---

## Introduction

To install the Apache Gravitino Trino connector, you should first deploy the Trino environment, and then install the Gravitino Trino connector plugin into Trino.
Refer to the [Deploying Trino documentation](https://trino.io/docs/current/installation/deployment.html) and do the following steps:

The examples in this document use Trino `469` by default.

## Get the Connector Package

Gravitino provides different Trino connector packages for different Trino version segments.
Choose the package by your Trino server version first.

| Trino server version | Connector package segment |
|----------------------|---------------------------|
| 435-439              | `trino-connector-435-439` |
| 440-445              | `trino-connector-440-445` |
| 446-451              | `trino-connector-446-451` |
| 452-468              | `trino-connector-452-468` |
| 469-472              | `trino-connector-469-472` |
| 473-478              | `trino-connector-473-478` |

For Trino `469`, choose the `trino-connector-469-472` package.

The release package naming format is:

`gravitino-trino-connector-<segment>-<version>.tar.gz`

For example:

`gravitino-trino-connector-469-472-<version>.tar.gz`

Get the package in the following ways:

1. Download a released package from [GitHub Releases](https://github.com/apache/gravitino/releases). For Trino `469`, download the `469-472` package:

```shell
cd /tmp
wget https://github.com/apache/gravitino/releases/download/<version>/gravitino-trino-connector-469-472-<version>.tar.gz
tar -zxvf gravitino-trino-connector-469-472-<version>.tar.gz
```

2. Build from source in the Gravitino project. For Trino `469`, build module `trino-connector-469-472`:

```shell
cd <gravitino-source-root>
./gradlew :trino-connector:trino-connector-469-472:assembleTrinoConnector
cd distribution
tar -zxvf gravitino-trino-connector-469-472-<version>.tar.gz
```

After unpacking, you can see the connector directory:

`gravitino-trino-connector-469-472-<version>`

## Install the Connector Package

1. Download and unpack the correct Gravitino Trino connector tarball for your Trino version.
2. Rename the unpacked connector directory to `gravitino`, and then copy it to the Trino plugin directory.
   Normally, the directory location is `Trino-server-<version>/plugin`, and the directory contains other catalogs used by Trino.
3. Add Trino JVM arguments `-Dlog4j.configurationFile=file:////etc/trino/log4j2.properties` to enable logging for the Gravitino Trino connector.
4. Update Trino coordinator configuration. 
   You need to set `catalog.management=dynamic`, The config location is `Trino-server-<version>/etc/config.properties`,  and the contents like:

```text
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
catalog.management=dynamic
discovery.uri=http://0.0.0.0:8080
```

## Example

Install the Gravitino Trino connector into the official Trino Docker image.

### Run the Container

Use the Docker command to create a container from the `trinodb/trino` image. Assign it the trino-gravitino name.
Run it in the background, and map the default Trino port, which is 8080, from inside the container to port 8080 on your machine.

```shell
docker run --name trino-gravitino -d -p 8080:8080 trinodb/trino:469
```

Run `docker ps` to check whether the container is running.


### Install the Trino Connector

Download the Gravitino Trino connector tarball for Trino `469` and unpack it.

```shell
cd /tmp
wget https://github.com/apache/gravitino/releases/download/<version>/gravitino-trino-connector-469-472-<version>.tar.gz
tar -zxvf gravitino-trino-connector-469-472-<version>.tar.gz
```

See the connector directory `gravitino-trino-connector-469-472-<version>` after unpacking.

Rename the connector directory to `gravitino`, then copy it to the Trino container's plugin directory.

```shell
mv /tmp/gravitino-trino-connector-469-472-<version> /tmp/gravitino
docker cp /tmp/gravitino trino-gravitino:/lib/trino/plugin
```

Check the plugin directory in the container.

```shell
docker exec -it trino-gravitino /bin/bash
cd /lib/trino/plugin
```

Now you can see the Gravitino Trino connector directory in the plugin directory.

### Configure Trino

Find the Trino configuration file `config.properties` in the directory `/etc/trino`. You need changed the file like this:

```text
#single node install config
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
discovery.uri=http://localhost:8080
catalog.management=dynamic
```

### Configure the Trino Connector

Assuming you have now started the Gravitino server on the host `gravitino-server-host` and already created a metalake named `test`, if those have not been prepared, refer to the [Gravitino getting started](../getting-started/index.md).

To configure Gravitino Trino connector correctly, you need to put the following configurations to the Trino configuration file `/etc/trino/catalog/gravitino.properties`.

```text
connector.name=gravitino
gravitino.uri=http://gravitino-server-host:8090
gravitino.metalake=test
```

- The `gravitino.name` defines which Gravitino Trino connector is used. It must be `gravitino`.
- The `gravitino.metalake` defines which metalake are used. It should exist in the Gravitino server.
- The `gravitino.uri` defines the connection information about Gravitino server. Make sure your container can access the Gravitino server.

Full configurations for Apache Gravitino Trino connector can be seen [here](configuration.md)

If you haven't created the metalake named `test`, you can use the following command to create it.

```shell
curl -X POST -H "Content-Type: application/json" -d '{"name":"test","comment":"comment","properties":{}}' http://gravitino-server-host:8090/api/metalakes
```

And then restart the Trino container to load the Gravitino Trino connector.

```shell
docker restart trino-gravitino
```

### Verify the Trino Connector

Use the Trino CLI to connect to the Trino container and run a query.

```text
docker exec -it trino-gravitino trino
trino> SHOW CATALOGS;
Catalog
------------------------
gravitino
jmx
memory
tpcds
tpch
system
```

See the `gravitino` catalog in the result set. This signifies the successful installation of the Gravitino Trino connector.

Assuming you have created a catalog named `test.jdbc-mysql` in the Gravitino server, or refer to [Create a Catalog](../manage-relational-metadata-using-gravitino.md#create-a-catalog). Then you can use the Trino CLI to connect to the Trino container and run a query like this.

```text
docker exec -it trino-gravitino trino
trino> SHOW CATALOGS;
Catalog
------------------------
gravitino
jmx
memory
tpcds
tpch
system
jdbc-mysql
```

The catalog named 'jdbc-mysql' is the catalog that you created by gravitino server, and you can use it to access the mysql database like other Trino catalogs.
