foms/README.md

62 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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.

# FOMS — Failover Management System
主备机切换管理系统。运行在管理中心 C 上,管理主机 A 和备机 B 之间的:
- **MySQL 主从复制** — 实时数据同步
- **文件目录同步** — rsync 定期同步
- **健康监控** — 节点心跳 + 复制状态
- **故障切换** — 自动检测 A 故障 → 切换到 B
- **故障切回** — A 修复后 → 切回 A
## 架构
```
管理中心 C (FOMS Web App)
├── 主机 A ←──MySQL复制/rsync──→ 备机 B
└── Agent 守护进程 (部署在 A & B)
```
## 快速开始
```bash
# 1. 构建
./build.sh
# 2. 配置 .env
vim .env
# 3. 初始化数据库 (手动执行 models/mysql.ddl.sql)
mysql -u root < models/mysql.ddl.sql
# 4. 注册RBAC权限
cd py3/bin && python ../../scripts/load_path.py
# 5. 启动
./start.sh
```
## 模块
| 模块 | 路径 | 说明 |
|------|------|------|
| 集群管理 | /clusters_list | 配置主备集群 |
| 节点管理 | /nodes_list | 注册A/B节点(SSH信息) |
| 数据库同步 | /sync_databases_list | MySQL主从复制配置 |
| 文件同步 | /sync_directories_list | rsync目录同步配置 |
## Agent部署
在主机A和备机B上
```bash
# 配置环境变量
export FOMS_MANAGEMENT_URL=http://C的IP:9080
export FOMS_NODE_ID=<节点ID>
export FOMS_AGENT_TOKEN=<安全令牌>
# 运行Agent
python3 scripts/foms-agent.py
```