Files
42_124/CT124_NocoDB操作手冊_20260622.md
Timmy 616b224e23 新增 CT124 NocoDB 操作手冊
操作/API/備份;對外 noco.timmy.edu.kg,並註記 DB 對 LAN 全開與預設弱帳密。

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

62 lines
2.7 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 NocoDB(自架 Airtable 替代)— 操作手冊
> 主機:CT124192.168.42.124Ubuntu 24.04 LXC | 位置:`/opt/noco`
> 用途:在關聯式資料庫上加一層「會動的試算表」UI + REST API,做內部工具 / no-code 應用
---
## 一、基本資訊
- 版本:**NocoDB 0.265.1**`nocodb/nocodb:latest`+ **PostgreSQL 16**(後端 metadata/資料庫)
- 容器:`noco_app``noco_postgres`(皆 `restart: unless-stopped`,共用 bridge `nocodb_net`
- 埠:`28080 → 8080`Web/API`5432 → 5432`Postgres,**對 LAN 開放**)
- 對外:**NPM 反代 `https://noco.timmy.edu.kg`**(注意:此服務用 `timmy.edu.kg`,非其他服務的 `lotimmy.com`)
- 後台:`https://noco.timmy.edu.kg/dashboard` | 官方:https://github.com/nocodb/nocodb
## 二、操作
```bash
cd /opt/noco
docker compose up -d # 啟動 / 套用設定Makefile 亦含 make up/down/restart/logs/ps
docker compose pull && docker compose up -d # 更新 image
docker compose logs -f noco
docker compose ps
```
## 三、存取
- Web/後台:`https://noco.timmy.edu.kg/dashboard`(內網 `http://192.168.42.124:28080`
- Super Admin:`admin@example.com` / `Admin@1234`(由 compose 的 `NC_ADMIN_EMAIL`/`NC_ADMIN_PASSWORD` 帶入)
- DB 連線(內網):`pg://noco_postgres:5432?u=root&p=password&d=d1`
## 四、資料
| 項目 | 位置 |
|---|---|
| Postgres 資料(metadata + 表) | `./pgdata`(→ 容器 `/var/lib/postgresql/data`,目前 ~65M) |
| NocoDB app data | `./nocodb`(→ `/usr/app/data`) |
備份:停服務或低流量時 `cp -a pgdata nocodb <備份目的地>`;或對 `noco_postgres``pg_dump`
## 五、REST API(v2)
`noco_clear_table.sh` 是清空某表所有記錄的範例,要點:
```bash
TOKEN="<API token,後台 → Account → Tokens 產生>"
TABLE_ID="<表 ID>"
BASE="https://noco.timmy.edu.kg/api/v2/tables/$TABLE_ID"
# 列記錄
curl -s -H "xc-token: $TOKEN" "$BASE/records?limit=1000" | jq '.list'
# 批次刪除(帶 [{"Id":..}] 陣列)
IDS=$(curl -s -H "xc-token: $TOKEN" "$BASE/records?limit=1000" | jq -c '[.list[]|{Id:.Id}]')
curl -X DELETE "$BASE/records" -H "xc-token: $TOKEN" -H "Content-Type: application/json" --data "$IDS"
```
## 六、注意事項(安全)
- **Postgres `:5432` 對 LAN 全開**,帳密 `root` / `password`(寫在 compose)。任何能連到 CT124 的人可直連 DB。要鎖:把 compose 的 `ports: 5432:5432` 拿掉(NocoDB 走內網即可),或改強密碼。
- **Super Admin 是弱/預設帳密**(`admin@example.com` / `Admin@1234`,明文在 compose)。建議登入後改密碼,並移除 compose 裡的 `NC_ADMIN_*`(那只在首次建立時需要)。
- 對外 443 經 NPM → 依賴 docker daemon 與 NPM 容器(見 [`CT124_故障復原_20260529.md`](CT124_故障復原_20260529.md));NPM 掛了 `noco.timmy.edu.kg` 不通。