Metabase logoBusiness Intelligence

Metabase

Công cụ business intelligence tự host, tạo biểu đồ và dashboard từ database mà không cần viết code.

Ghi chú review

Mặc định dùng H2 embedded database. Nên chuyển sang PostgreSQL cho production để đảm bảo ổn định.

Hướng dẫn deploy

Chạy một container Docker đơn giản. Nên dùng PostgreSQL làm metabase database cho production.

  1. Tạo thư mục dữ liệu cho Metabase.
  2. Chạy container với biến môi trường cấu hình database backend.
  3. Truy cập web UI tại port 3000 và hoàn thành setup wizard.
  4. Kết nối data sources (PostgreSQL, MySQL, etc.) để truy vấn.
  5. Tạo questions và dashboards, phân quyền cho team.
Backup:Backup Metabase application database (PostgreSQL). Dashboards và questions đều nằm trong database này.

Copy để chạy trên server

Dùng từng block riêng: lưu compose trước, hoặc copy script bash để tạo file và chạy container.

docker-compose.ymlyaml
services:
  metabase:
    image: metabase/metabase:latest
    container_name: metabase
    environment:
      MB_DB_TYPE: postgres
      MB_DB_HOST: postgres
      MB_DB_PORT: "5432"
      MB_DB_DBNAME: metabase
      MB_DB_USER: metabase
      MB_DB_PASS: CHANGEME_db_password # CHANGE THIS
    ports:
      - "3000:3000"
    depends_on:
      - postgres
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    container_name: metabase_postgres
    environment:
      POSTGRES_USER: metabase
      POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
      POSTGRES_DB: metabase
    volumes:
      - ./postgres:/var/lib/postgresql/data
    restart: unless-stopped
setup.shbash
#!/usr/bin/env bash
set -euo pipefail

sudo mkdir -p /opt/metabase
sudo chown "$USER":"$USER" /opt/metabase
cd /opt/metabase

cat > docker-compose.yml <<'COMPOSE'
services:
  metabase:
    image: metabase/metabase:latest
    container_name: metabase
    environment:
      MB_DB_TYPE: postgres
      MB_DB_HOST: postgres
      MB_DB_PORT: "5432"
      MB_DB_DBNAME: metabase
      MB_DB_USER: metabase
      MB_DB_PASS: CHANGEME_db_password # CHANGE THIS
    ports:
      - "3000:3000"
    depends_on:
      - postgres
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    container_name: metabase_postgres
    environment:
      POSTGRES_USER: metabase
      POSTGRES_PASSWORD: CHANGEME_db_password # CHANGE THIS
      POSTGRES_DB: metabase
    volumes:
      - ./postgres:/var/lib/postgresql/data
    restart: unless-stopped
COMPOSE

docker compose up -d
echo "Metabase is running on http://SERVER_IP:3000"

Stack

ClojureJavaDocker