Files
42_124/CT124_Redash操作手冊_20260622.md
Timmy 5619fbe4cb 新增 CT124 Redash 操作手冊
6 容器架構、操作、create_db;重點提醒 DB 在匿名 volume 的備份風險與 pg_dump 解法。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 22:07:40 +08:00

53 lines
2.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CT124 Redash(自架 SQL 查詢/儀表板)— 操作手冊
> 主機:CT124192.168.42.124Ubuntu 24.04 LXC | 位置:`/opt/redash`
> 用途:連各種資料庫,寫 SQL → 視覺化 / 儀表板 / 排程 / 告警
---
## 一、基本資訊
- 版本:**Redash 10.1.0**`redash/redash:10.1.0.b50633`,官方正式版 image
- 設定檔:**`compose.yaml`**(非 `docker-compose.yml`+ `.env`(放 `REDASH_SECRET_KEY` / `REDASH_COOKIE_SECRET`)
- `/opt/redash` 是整包 Redash 原始碼 checkout,但跑的是官方 image,不自行編譯。
- 對外:**僅 LAN**`redash.lotimmy.com``redash.timmy.edu.kg` 皆不解析,`REDASH_HOST=http://localhost:5001`
## 二、容器(6 個)
| 容器 | image | 角色 | Port |
|---|---|---|---|
| `redash-server-1` | redash 10.1.0 | Web/API | `5001 → 5000` |
| `redash-worker-1` | redash 10.1.0 | 查詢/排程執行 worker | — |
| `redash-scheduler-1` | redash 10.1.0 | 排程器 | — |
| `redash-postgres-1` | postgres:15-alpine | metadata DB`trust` 認證,內網) | — |
| `redash-redis-1` | redis:7-alpine | queue / cache | — |
| `redash-email-1` | maildev | 攔截外送信件(告警測試用) | `1025`(SMTP) / `1080`(Web) |
## 三、存取
- Web:`http://192.168.42.124:5001`
- 寄信測試/告警信箱(maildev UI):`http://192.168.42.124:1080`
## 四、操作
```bash
cd /opt/redash
docker compose up -d
docker compose ps
docker compose logs -f server
docker compose restart
# 首次 / 重建 DB schema(myfile.txt 記的就是這條)
docker compose run --rm server create_db
```
## 五、注意事項
- **⚠️ Postgres 資料在「匿名」Docker volume**(`/var/lib/docker/volumes/<hash>/_data`),**不在 `/opt/redash`**,`compose.yaml` 也沒宣告 named volume。風險:
- `docker compose down -v` 會**整個刪掉** → 資料全失。
- 備份 `/opt/redash` 目錄**抓不到 DB**。
- 備份正解:`docker exec redash-postgres-1 pg_dump -U postgres postgres > redash-$(date +%F).sql`
- 想長治久安:在 compose 的 `postgres``volumes: [./pgdata:/var/lib/postgresql/data]`,遷移後改用具名/綁定卷。
- Postgres 用 `POSTGRES_HOST_AUTH_METHOD=trust`(無密碼),但**未對外開 port**,僅 docker 內網,風險可控。
- 殘留檔:`compose.yaml_BACKUP_20260205160912``myfile.txt` 為安裝時的暫存,可留可刪。