Redash 修復登入 500:DB 卷孤兒化,釘回 bdc790
斷電重建後 postgres 掛到新空匿名卷導致無 schema → 改用具名 external volume 釘到原始資料卷;手冊「資料卷」段改寫為事故記錄+備份正解。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -41,12 +41,24 @@ docker compose restart
|
||||
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 資料卷現已**釘到具名 external volume**(2026-06-22 修正):
|
||||
```yaml
|
||||
# compose.yaml
|
||||
postgres:
|
||||
volumes: [redash_pgdata:/var/lib/postgresql/data]
|
||||
volumes:
|
||||
redash_pgdata:
|
||||
external: true
|
||||
name: bdc790164a878cda6a5ad9c8ff7f4c08e8b2f79c4682231e0301a523201c3c1a
|
||||
```
|
||||
- **歷史事故(2026-06-22,登入 500)**:原本 postgres 用**匿名 volume**,五月斷電後 docker 重建時 compose 開了**新的空匿名卷**,把有資料的 `bdc790` 孤兒化 → DB 無 `organizations` 表 → `/login` 500。修法:找回 `bdc790` 並用上面的 external volume 釘死。
|
||||
- 孤兒空卷 `2f327adc…`、`00b892ea…`(PG15 空庫)可清:`docker volume rm <hash>`(確認沒用到再刪)。
|
||||
- **備份**(資料仍只在 docker volume,不在 `/opt/redash`):
|
||||
```bash
|
||||
docker exec redash-postgres-1 pg_dump -U postgres postgres > redash-$(date +%F).sql
|
||||
```
|
||||
- ⚠️ `docker compose down -v` 會刪卷;`external: true` 的卷 compose 不會自動刪,稍安全,但仍別亂下 `-v`。
|
||||
- Postgres 用 `POSTGRES_HOST_AUTH_METHOD=trust`(無密碼),但**未對外開 port**,僅 docker 內網,風險可控。
|
||||
- 殘留檔:`compose.yaml_BACKUP_20260205160912`、`myfile.txt` 為安裝時的暫存,可留可刪。
|
||||
- 殘留檔:`compose.yaml_BACKUP_*`、`myfile.txt` 為安裝暫存,可留可刪。
|
||||
|
||||
Reference in New Issue
Block a user