Một máy chủ là đủ cho hầu hết các nhóm. Chỉ thêm máy khi MOF phải tiếp tục chạy khi một máy chủ gặp sự cố, hoặc khi có quá nhiều tài khoản cloud khiến việc đồng bộ liên tục phải xếp hàng.
Vai trò của từng tiến trình
| Vai trò | Cài đặt | Web | Đồng bộ |
|---|---|---|---|
| MOF đầy đủ | Không đặt (mặc định) | Có | Có |
| Worker | RK_CONFIG_0_CONTENT_MODE_WORKER=true | Không | Có |
| Chỉ web | RK_CONFIG_0_CONTENT_MODE_WEB=true | Có | Không |
Admin → Hệ thống → Tiến trình MOF hiển thị mọi tiến trình đang chạy và vai trò của nó.
Tính sẵn sàng cao
- Trên mỗi máy chủ, dùng compose.yaml cho PostgreSQL bên ngoài với cùng một cơ sở dữ liệu.
- Khởi động một máy chủ và lấy mật khẩu Admin từ log của nó, sau đó khởi động các máy chủ còn lại.
- Trỏ load balancer tới cổng 80 trên mỗi máy chủ, với health check chủ động tới
/v1/mof/site-infovài giây một lần.
Health check đi qua Dash tới MOF, nên máy chủ có MOF đã dừng sẽ trả về 502 và bị loại ra. Nếu không có health check chủ động (proxy chỉ kiểm tra thụ động), request đầu tiên sau sự cố sẽ chờ hết timeout rồi mới chuyển sang máy chủ khác.
Dùng cùng phiên bản image ở mọi nơi. Với OAuth qua trình duyệt, MOF_PUBLIC_URL và MOF_MCP_OAUTH_SECRET cũng phải giống nhau. Khóa đăng nhập, khóa mã hóa và giấy phép nằm trong cơ sở dữ liệu; không cần làm gì thêm.
Trên Kubernetes, MOF, MCP và Dash là các Deployment riêng, vì vậy hãy thêm replica: kubectl -n mof scale deployment/mof deployment/dash --replicas=2. Nâng cấp vẫn dừng mọi Pod MOF trong thời gian ngắn (strategy Recreate), để tất cả replica chạy cùng một phiên bản.
Thêm worker
Dùng cùng cơ sở dữ liệu và phiên bản MOF với triển khai chính. Worker không mở cổng nào.
Tải xuống compose.yaml
Docker Hub · MOF v2.0.15
Tải xuống compose.yaml ↓Xem tệp và image
# 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
Tải xuống compose.yaml ↓Xem tệp và image
# 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
Tải xuống compose.yaml ↓Xem tệp và image
# 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.15Kết nối cơ sở dữ liệu
Điền cùng thông tin kết nối cơ sở dữ liệu như triển khai chính:
RK_POSTGRES_0_ADDR- Địa chỉ:cổng
RK_POSTGRES_0_USER- Tên người dùng
RK_POSTGRES_0_PASS- Mật khẩu
Dữ liệu hiện có và quyền truy cập cơ sở dữ liệu
Role cần quyền login và CREATEDB. Thay đổi địa chỉ không di chuyển dữ liệu hay đặt lại mật khẩu. Hãy sao lưu và khôi phục riêng trước khi chuyển cơ sở dữ liệu.
Khởi động
docker compose config --quiet
docker compose up -d
docker compose psĐể thêm worker trên máy này:
docker compose up -d --scale mof-worker=3
docker compose logs --tail=100 mof-workerMỗi worker chạy đồng thời 2 job đồng bộ (hóa đơn, tài nguyên, xuất dữ liệu) và 2 job vận hành (xóa tài khoản, dọn hóa đơn, áp dụng tag ảo). Bỏ chú thích và tăng RK_CONFIG_0_CONTENT_JOBS_SYNCWORKERS trong compose.yaml nếu máy còn dư bộ nhớ; RK_CONFIG_0_CONTENT_JOBS_OPSWORKERS làm tương tự cho job vận hành.