เซิร์ฟเวอร์เดียวเพียงพอสำหรับทีมส่วนใหญ่ เพิ่มเครื่องก็ต่อเมื่อ MOF ต้องทำงานต่อได้แม้เซิร์ฟเวอร์ล่ม หรือเมื่อมีบัญชีคลาวด์มากจนการซิงค์ต้องเข้าคิวตลอด
หน้าที่ของแต่ละโปรเซส
| บทบาท | การตั้งค่า | Web | ซิงค์ |
|---|---|---|---|
| MOF เต็มรูปแบบ | ไม่ตั้ง (ค่าเริ่มต้น) | ใช่ | ใช่ |
| Worker | RK_CONFIG_0_CONTENT_MODE_WORKER=true | ไม่ | ใช่ |
| เฉพาะ web | RK_CONFIG_0_CONTENT_MODE_WEB=true | ใช่ | ไม่ |
Admin → ระบบ → โปรเซสของ MOF แสดงทุกโปรเซสที่กำลังทำงานและบทบาท
ความพร้อมใช้งานสูง
- บนทุกเซิร์ฟเวอร์ ให้ใช้ compose.yaml สำหรับ PostgreSQL ภายนอก กับฐานข้อมูลเดียวกัน
- เริ่มเซิร์ฟเวอร์หนึ่งเครื่องแล้วดึงรหัสผ่าน Admin จาก log จากนั้นจึงเริ่มเครื่องอื่น
- ชี้ load balancer ไปที่พอร์ต 80 ของแต่ละเซิร์ฟเวอร์ พร้อม active health check ที่
/v1/mof/site-infoทุกไม่กี่วินาที
การตรวจสอบจะผ่าน Dash ไปยัง MOF ดังนั้นเซิร์ฟเวอร์ที่ MOF หยุดทำงานจะตอบ 502 และถูกนำออก หากไม่มี active check (พร็อกซีที่ตรวจแบบ passive อย่างเดียว) คำขอแรกหลังเกิดความล้มเหลวจะต้องรอจน timeout ก่อนย้ายไปเซิร์ฟเวอร์อื่น
ใช้เวอร์ชันอิมเมจเดียวกันทุกที่ หากใช้ OAuth ผ่านเบราว์เซอร์ MOF_PUBLIC_URL และ MOF_MCP_OAUTH_SECRET ต้องตรงกันด้วย คีย์ลงชื่อเข้าใช้ คีย์เข้ารหัส และไลเซนส์อยู่ในฐานข้อมูล ไม่ต้องทำอะไรเพิ่ม
บน Kubernetes นั้น MOF, MCP และ Dash เป็น Deployment แยกกัน จึงให้เพิ่ม replica แทน: kubectl -n mof scale deployment/mof deployment/dash --replicas=2 การอัปเกรดยังคงหยุดทุก Pod ของ MOF ชั่วครู่ (strategy Recreate) เพื่อให้ทุก replica รันเวอร์ชันเดียวกัน
เพิ่ม worker
ใช้ฐานข้อมูลและเวอร์ชัน MOF เดียวกับ deployment หลัก worker ไม่เปิดพอร์ตใดๆ
ดาวน์โหลด compose.yaml
Docker Hub · MOF v2.0.15
ดาวน์โหลด compose.yaml ↓ดูไฟล์และอิมเมจ
# MOF v2.0.15 — Linux amd64 / dockerhub
# Use the same database connection and MOF version as the main deployment.
# Private-network PostgreSQL without TLS. TLS-only databases are not supported by this release.
name: mof-worker
x-logging: &logging
driver: json-file
options:
max-size: "20m"
max-file: "5"
services:
mof-worker:
image: mofcloud/mof:v2.0.15
restart: unless-stopped
logging: *logging
environment:
RK_POSTGRES_0_ADDR: "db.example.com:5432"
RK_POSTGRES_0_USER: "mof"
RK_POSTGRES_0_PASS: "REPLACE_WITH_YOUR_DATABASE_PASSWORD"
RK_CONFIG_0_CONTENT_MODE_WORKER: "true"
# Optional, default 2: jobs run at the same time in this process, for syncs (bills,
# resources, exports) and ops (delete an account, purge bills, apply a virtual tag filter).
# RK_CONFIG_0_CONTENT_JOBS_SYNCWORKERS: "2"
# RK_CONFIG_0_CONTENT_JOBS_OPSWORKERS: "2"
volumes:
- offer-cache:/usr/src/mof/offer-cache
volumes:
offer-cache:
mofcloud/mof:v2.0.15Alibaba Cloud ACR · MOF v2.0.15
ดาวน์โหลด compose.yaml ↓ดูไฟล์และอิมเมจ
# MOF v2.0.15 — Linux amd64 / acr
# Use the same database connection and MOF version as the main deployment.
# Private-network PostgreSQL without TLS. TLS-only databases are not supported by this release.
name: mof-worker
x-logging: &logging
driver: json-file
options:
max-size: "20m"
max-file: "5"
services:
mof-worker:
image: registry.cn-hangzhou.aliyuncs.com/mofcloud/mof:v2.0.15
restart: unless-stopped
logging: *logging
environment:
RK_POSTGRES_0_ADDR: "db.example.com:5432"
RK_POSTGRES_0_USER: "mof"
RK_POSTGRES_0_PASS: "REPLACE_WITH_YOUR_DATABASE_PASSWORD"
RK_CONFIG_0_CONTENT_MODE_WORKER: "true"
# Optional, default 2: jobs run at the same time in this process, for syncs (bills,
# resources, exports) and ops (delete an account, purge bills, apply a virtual tag filter).
# RK_CONFIG_0_CONTENT_JOBS_SYNCWORKERS: "2"
# RK_CONFIG_0_CONTENT_JOBS_OPSWORKERS: "2"
volumes:
- offer-cache:/usr/src/mof/offer-cache
volumes:
offer-cache:
registry.cn-hangzhou.aliyuncs.com/mofcloud/mof:v2.0.15GHCR · MOF v2.0.15
ดาวน์โหลด compose.yaml ↓ดูไฟล์และอิมเมจ
# MOF v2.0.15 — Linux amd64 / ghcr
# Use the same database connection and MOF version as the main deployment.
# Private-network PostgreSQL without TLS. TLS-only databases are not supported by this release.
name: mof-worker
x-logging: &logging
driver: json-file
options:
max-size: "20m"
max-file: "5"
services:
mof-worker:
image: ghcr.io/mofcloud/mof:v2.0.15
restart: unless-stopped
logging: *logging
environment:
RK_POSTGRES_0_ADDR: "db.example.com:5432"
RK_POSTGRES_0_USER: "mof"
RK_POSTGRES_0_PASS: "REPLACE_WITH_YOUR_DATABASE_PASSWORD"
RK_CONFIG_0_CONTENT_MODE_WORKER: "true"
# Optional, default 2: jobs run at the same time in this process, for syncs (bills,
# resources, exports) and ops (delete an account, purge bills, apply a virtual tag filter).
# RK_CONFIG_0_CONTENT_JOBS_SYNCWORKERS: "2"
# RK_CONFIG_0_CONTENT_JOBS_OPSWORKERS: "2"
volumes:
- offer-cache:/usr/src/mof/offer-cache
volumes:
offer-cache:
ghcr.io/mofcloud/mof:v2.0.15การเชื่อมต่อฐานข้อมูล
กรอกการเชื่อมต่อฐานข้อมูลเดียวกับ deployment หลัก:
RK_POSTGRES_0_ADDR- ที่อยู่:พอร์ต
RK_POSTGRES_0_USER- ชื่อผู้ใช้
RK_POSTGRES_0_PASS- รหัสผ่าน
ข้อมูลเดิมและการเข้าถึงฐานข้อมูล
role ต้องมีสิทธิ์ login และ CREATEDB การเปลี่ยนที่อยู่ไม่ได้ย้ายข้อมูลหรือรีเซ็ตรหัสผ่าน ให้สำรองและกู้คืนแยกต่างหากก่อนเปลี่ยนฐานข้อมูล
เริ่มทำงาน
docker compose config --quiet
docker compose up -d
docker compose psเพิ่ม worker บนเครื่องนี้:
docker compose up -d --scale mof-worker=3
docker compose logs --tail=100 mof-workerworker แต่ละตัวรันงานซิงค์ 2 งาน (บิล ทรัพยากร การส่งออก) และงานปฏิบัติการ 2 งาน (ลบบัญชี ล้างบิล ใช้แท็กเสมือน) พร้อมกัน หากเครื่องมีหน่วยความจำเหลือ ให้ยกเลิกคอมเมนต์และเพิ่มค่า RK_CONFIG_0_CONTENT_JOBS_SYNCWORKERS ใน compose.yaml ส่วน RK_CONFIG_0_CONTENT_JOBS_OPSWORKERS ใช้กับงานปฏิบัติการในแบบเดียวกัน