Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#834] feat(docker): Gravitino complete experience docker environment (#917)

Xun Liu254a878b4825
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 69e5cedeba..a7ddbdc87c 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -12,6 +12,8 @@ on:
- 'gravitino'
- 'gravitino-ci-hive'
- 'gravitino-ci-trino'
+ - 'trino'
+ - 'hive'
tag:
description: 'Docker tag to apply to this image'
required: true
@@ -40,6 +42,12 @@ jobs:
elif [ "${{ github.event.inputs.image }}" == "gravitino" ]; then
echo "image_type=gravitino" >> $GITHUB_ENV
echo "image_name=datastrato/gravitino" >> $GITHUB_ENV
+ elif [ "${{ github.event.inputs.image }}" == "trino" ]; then
+ echo "image_type=trino" >> $GITHUB_ENV
+ echo "image_name=datastrato/trino" >> $GITHUB_ENV
+ elif [ "${{ github.event.inputs.image }}" == "hive" ]; then
+ echo "image_type=hive" >> $GITHUB_ENV
+ echo "image_name=datastrato/hive" >> $GITHUB_ENV
fi
- name: Check publish Docker token
diff --git a/dev/docker/README.md b/dev/docker/README.md
index 083b160852..21c25305d9 100644
--- a/dev/docker/README.md
+++ b/dev/docker/README.md
@@ -23,7 +23,8 @@ It can be utilized to test all catalog and connector modules within Gravitino.
docker run --rm -d -p 8090:8090 datastrato/gravitino
```
-### 0.3.0-SNAPSHOT
+### gravitino:0.3.0-SNAPSHOT
+- Docker image `datastrato/gravitino:0.3.0-SNAPSHOT`
- Gravitino Server
- Expose ports:
- `8090` Gravitino Web UI
@@ -35,7 +36,7 @@ docker run --rm -d -p 8090:8090 datastrato/gravitino
docker run --rm -d -p 9000:9000 -p 9083:9083 -p 10000:10000 -p 10002:10002 -p 50010:50010 -p 50070:50070 -p 50075:50075 datastrato/gravitino-ci-hive
```
-### 0.1.0
+### gravitino-ci-hive:0.1.0
- Docker image `datastrato/gravitino-ci-hive:0.1.0`
- `hadoop-2.7.3`
- `hive-2.3.9`
@@ -50,30 +51,30 @@ docker run --rm -d -p 9000:9000 -p 9083:9083 -p 10000:10000 -p 10002:10002 -p 50
- `10000` HiveServer2
- `10002` HiveServer2 HTTP
-### 0.1.1
+### gravitino-ci-hive:0.1.1
- base on `datastrato/gravitino-ci-hive:0.1.0`
- Modify HDFS/YARN/HIVE `MaxPermSize` from `8GB` to `128MB`
- Modify `HADOOP_HEAPSIZE` from `8192` to `128
-### 0.1.2
+### gravitino-ci-hive:0.1.2
- base on `datastrato/gravitino-ci-hive:0.1.1`
- Modify `fs.defaultFS` from `local` to `0.0.0.0` in the `core-site.xml` file.
- Expose `9000` port int the `Dockerfile` file.
-### 0.1.3
+### gravitino-ci-hive:0.1.3
- change mysql bind-address from `127.0.0.1` to `0.0.0.0`
- add `iceberg` to mysql users with password `iceberg`
- export `3306` port for mysql
-### 0.1.4
+### gravitino-ci-hive:0.1.4
- Config HDFS DataNode data transfer address to `0.0.0.0:50010` explicitly
- Map container hostname to `127.0.0.1` before starting Hadoop
- Expose `50010` port for the HDFS DataNode
-### 0.1.5
+### gravitino-ci-hive:0.1.5
- Rollback `Map container hostname to 127.0.0.1 before starting Hadoop` of `datastrato/gravitino-ci-hive:0.1.4`
-### 0.1.6
+### gravitino-ci-hive:0.1.6
- No start YARN when container startup
- Removed expose ports:
- `22` SSH
@@ -86,8 +87,21 @@ docker run --rm -d -p 9000:9000 -p 9083:9083 -p 10000:10000 -p 10002:10002 -p 50
docker run --rm -it -p 8080:8080 datastrato/gravitino-ci-trino
```
-### 0.1.0
+### gravitino-ci-trino:0.1.0
- Docker image `datastrato/gravitino-ci-trino:0.1.0`
- Base on `trinodb/trino:426` and removed some unused plugins from it.
- Expose ports:
- - `8080` Trino JDBC port
\ No newline at end of file
+ - `8080` Trino JDBC port
+
+## Hive (For experience only)
+### hive:2.7.3-no-yarn
+- Docker image `datastrato/hive:2.7.3-no-yarn`
+- `hadoop-2.7.3`
+- `hive-2.3.9`
+- Not start YARN when container startup
+
+## Trino (For experience only)
+### trino:426-gravitino-0.3.0-SNAPSHOT
+- Docker image `datastrato/trino:426-gravitino-0.3.0-SNAPSHOT`
+- Base on `trino:462`
+- Add `Gravitino` `trino-connector` `0.3.0-SNAPSHOT` to Trino plugin directory
diff --git a/dev/docker/playground/README.md b/dev/docker/playground/README.md
new file mode 100644
index 0000000000..59781a7653
--- /dev/null
+++ b/dev/docker/playground/README.md
@@ -0,0 +1,51 @@
+<!--
+ Copyright 2023 Datastrato.
+ This software is licensed under the Apache License version 2.
+-->
+# Playground
+This is a complete Gravitino Docker runtime environment with `Hive`, `Hdfs`, `Trino`, and `Gravitno` Server. just execute the `./launch-playground.sh` script.
+Depending on your network, the startup may take 3-5 minutes.
+Once the playground environment has started, you can open http://localhost:8090 to access the Gravitino Web UI.
+
+## Startup playground
+```shell
+./launch-playground.sh
+```
+
+## Experience Gravitino with Trino SQL
+
+1. Login to Gravitino playground Trino Docker container using the following command.
+
+```shell
+docker exec -it playground-trino bash
+````
+
+2. Open Trino CLI in the container.
+
+```shell
+trino@d2bbfccc7432:/$ trino
+```
+
+3. Use follow SQL to test in the Trino CLI.
+
+```SQL
+SHOW CATALOGS;
+
+CREATE SCHEMA "metalake_demo.catalog_demo".db1
+ WITH (location = 'hdfs://hive:9000/user/hive/warehouse/db1.db');
+
+SHOW CREATE SCHEMA "metalake_demo.catalog_demo".db1;
+
+CREATE TABLE "metalake_demo.catalog_demo".db1.table_001
+(
+ name varchar,
+ salary varchar
+)
+WITH (
+ format = 'TEXTFILE'
+);
+
+INSERT INTO "metalake_demo.catalog_demo".db1.table_001 (name, salary) VALUES ('sam', '11');
+
+SELECT * FROM "metalake_demo.catalog_demo".db1.table_001;
+```
diff --git a/dev/docker/playground/docker-compose.yaml b/dev/docker/playground/docker-compose.yaml
new file mode 100644
index 0000000000..ada69951fa
--- /dev/null
+++ b/dev/docker/playground/docker-compose.yaml
@@ -0,0 +1,68 @@
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+version: '3.0'
+services:
+ hive:
+ image: datastrato/hive:2.7.3-no-yarn
+ ports:
+ - "3306:3306"
+ - "9000:9000"
+ - "9083:9083"
+ container_name: playground-hive
+ environment:
+ - HADOOP_USER_NAME=root
+ healthcheck:
+ test: ["CMD", "/tmp/check-status.sh"]
+ interval: 10s
+ timeout: 60s
+ retries: 5
+ deploy:
+ resources:
+ limits:
+ cpus: "1"
+ memory: 1G
+
+ gravitino:
+ image: datastrato/gravitino:0.3.0-SNAPSHOT
+ ports:
+ - "8090:8090"
+ container_name: playground-gravitino
+ depends_on:
+ hive :
+ condition: service_healthy
+ volumes:
+ - ./healthcheck:/tmp/healthcheck
+ deploy:
+ resources:
+ limits:
+ cpus: "0.5"
+ memory: 500M
+ healthcheck:
+ test: ["CMD", "/tmp/healthcheck/gravitino-healthcheck.sh"]
+ interval: 5s
+ timeout: 10s
+ retries: 5
+
+ trino:
+ image: datastrato/trino:426-gravitino-0.3.0-SNAPSHOT
+ ports:
+ - "8080:8080"
+ container_name: playground-trino
+ environment:
+ - HADOOP_USER_NAME=root
+ - GRAVITINO_HOST_IP=gravitino
+ - GRAVITINO_HOST_PORT=8090
+ - GRAVITINO_METALAKE_NAME=metalake_demo
+ - HIVE_HOST_IP=hive
+ depends_on:
+ hive :
+ condition: service_healthy
+ gravitino :
+ condition: service_healthy
+ deploy:
+ resources:
+ limits:
+ cpus: "1"
+ memory: 1G
diff --git a/dev/docker/playground/healthcheck/gravitino-healthcheck.sh b/dev/docker/playground/healthcheck/gravitino-healthcheck.sh
new file mode 100755
index 0000000000..25ac8e5189
--- /dev/null
+++ b/dev/docker/playground/healthcheck/gravitino-healthcheck.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+set -ex
+
+# Since trino-connector needs to connect Gravitino service, get the default metalake
+# Create metalake
+response=$(curl -X POST -H "Content-Type: application/json" -d '{"name":"metalake_demo","comment":"comment","properties":{}}' http://127.0.0.1:8090/api/metalakes)
+if echo "$response" | grep -q "\"code\":0"; then
+ true # Placeholder, do nothing
+else
+ echo "Metalake metalake_demo create failed"
+ exit 1
+fi
+
+# Check metalake if created
+response=$(curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8090/api/metalakes)
+if echo "$response" | grep -q "metalake_demo"; then
+ echo "Metalake metalake_demo successfully created"
+else
+ echo "Metalake metalake_demo create failed"
+ exit 1
+fi
+
+# Create Hive catalog for experience Gravitino service
+curl -X POST -H "Content-Type: application/json" -d '{"name":"catalog_demo","type":"RELATIONAL", "provider":"hive", "comment":"comment","properties":{"metastore.uris":"thrift://hive:9083"}}' http://127.0.0.1:8090/api/metalakes/metalake_demo/catalogs
+
+# Check catalog if created
+response=$(curl -X GET -H "Content-Type: application/json" http://127.0.0.1:8090/api/metalakes/metalake_demo/catalogs)
+if echo "$response" | grep -q "catalog_demo"; then
+ echo "Catalog catalog_demo successfully created"
+else
+ echo "Catalog catalog_demo create failed"
+ exit 1
+fi
+
+exit 0
\ No newline at end of file
diff --git a/dev/docker/playground/healthcheck/trino-healthcheck.sh b/dev/docker/playground/healthcheck/trino-healthcheck.sh
new file mode 100755
index 0000000000..a14ed068dc
--- /dev/null
+++ b/dev/docker/playground/healthcheck/trino-healthcheck.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+set -ex
+
+# Because trino-connector must first synchronize a default metalake from the Gravitino server
+response=$(trino --execute "SHOW CATALOGS LIKE 'metalake_demo.catalog_demo'")
+if echo "$response" | grep -q "metalake_demo.catalog_demo"; then
+ echo "Gravitino Trino connector has finished synchronizing metadata"
+else
+ echo "Gravitino Trino connector is not yet finished synchronizing metadata"
+ exit 1
+fi
+
+exit 0
\ No newline at end of file
diff --git a/dev/docker/playground/launch-playground.sh b/dev/docker/playground/launch-playground.sh
new file mode 100755
index 0000000000..d9eb1a4ec8
--- /dev/null
+++ b/dev/docker/playground/launch-playground.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright 2023 Datastrato.
+# This software is licensed under the Apache License version 2.
+#
+#set -ex
+playground_dir="$(dirname "${BASH_SOURCE-$0}")"
+playground_dir="$(cd "${playground_dir}">/dev/null; pwd)"
+
+if command -v docker &> /dev/null
+then
+ true # Placeholder, do nothing
+else
+ echo "ERROR: No docker service environment found, please install docker first."
+ exit
+fi
+
+cd ${playground_dir}
+docker-compose up
+
+# Clean Docker containers when you quit this script
+docker-compose down
\ No newline at end of file
diff --git a/dev/docker/tools/mac-docker-connector.sh b/dev/docker/tools/mac-docker-connector.sh
index cbb7ec2415..6f71ad5ccd 100755
--- a/dev/docker/tools/mac-docker-connector.sh
+++ b/dev/docker/tools/mac-docker-connector.sh
@@ -31,7 +31,7 @@ fi
# Start the Docker image on which the docker-connector server depends.
docker stop desktop-connector 2>/dev/null
docker rm desktop-connector 2>/dev/null
-docker run -it -d --rm --net host --cap-add NET_ADMIN --name desktop-connector wenjunxiao/desktop-docker-connector
+docker run -it -d --restart always --net host --cap-add NET_ADMIN --name desktop-connector wenjunxiao/desktop-docker-connector
# Start docker-connector server
echo "Start docker-connector requires root privileges, Please enter the root password."