Files
JayuCloud/docs/architecture/架构设计.md
T

360 lines
3.0 KiB
Markdown
Raw 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.
````md
# 双中心容灾架构(当前阶段推荐方案)
## 一、整体架构目标
当前阶段目标:
- 低成本
- 高稳定
- 快速容灾切换
- 简单易维护
当前不建议:
- 双活
- K8S
- Redis Cluster
- MySQL 双主
- 跨中心 Nacos 集群
推荐模式:
```text
主中心生产 + 备中心接管
````
---
# 二、最终部署结构
## 中心A(主生产中心)
```text
mysql01(主)
mysql02(从)
redis01(主)
redis02(从)
nacos01
nacos02
nacos03
gateway01
gateway02
core01
core02
```
---
## 中心B(容灾中心)
```text
mysql03(异地热备)
redis03(从)
nacos04(独立)
gateway03
core03
```
---
# 三、MySQL 架构
## 推荐结构
```text
mysql01(主)
↓
mysql02(同城从)
↓
mysql03(异地热备)
```
---
## 推荐配置
开启:
* GTID
* 半同步复制
不建议:
* 双主
* MGR
* 多主写入
---
## mysql03 定位
mysql03 不再是冷备。
改为:
```text
异地热备
```
特点:
* 实时同步
* 可读
* 可快速切换
---
# 四、Redis 架构
## 推荐结构
```text
redis01(master)
↓
redis02(slave)
↓
redis03(异地slave)
```
---
## Sentinel 部署
```text
sentinel01(A)
sentinel02(A)
sentinel03(B)
```
---
## 不建议
不建议:
```text
Redis Cluster
```
原因:
* 跨机房延迟高
* 维护复杂
* 容易抖动
---
# 五、Nacos 架构
## 中心A
```text
nacos01
nacos02
nacos03
```
组成集群。
---
## 中心B
```text
nacos04
```
独立运行。
---
## 注意
不要:
```text
跨中心组成一个Nacos集群
```
原因:
* Raft 对延迟敏感
* 容易脑裂
* 稳定性差
---
# 六、网关架构
## 当前结构
```text
gateway01
gateway02
gateway03
```
---
## nginx 推荐配置
默认:
```text
流量走A中心
```
A中心故障:
```text
切换到B中心
```
---
# 七、服务调用原则
必须遵守:
```text
A服务调用A资源
B服务调用B资源
```
不要:
```text
A调用B Redis
A调用B MySQL
```
否则:
* 延迟增加
* 网络依赖增强
* 故障率提升
---
# 八、最终推荐加购
## 必加
中心B:
```text
新增 nacos04
```
这是当前最重要的。
原因:
当前所有服务注册中心都在A。
---
## 推荐加
如果预算允许:
```text
新增 core04
```
避免:
```text
B中心只有一个core节点
```
形成单点。
---
# 九、最终推荐方案总结
## 数据库
```text
mysql01 主
mysql02 从
mysql03 异地热备
```
开启:
```text
GTID + 半同步
```
---
## Redis
```text
redis01 主
redis02 从
redis03 异地从
```
增加:
```text
3 Sentinel
```
---
## Nacos
```text
A:
nacos01 02 03
B:
nacos04(独立)
```
---
## 网关
```text
默认走A
A挂切B
```
---
# 十、当前阶段核心思想
当前最重要的不是:
```text
技术最先进
```
而是:
```text
简单
稳定
可维护
可快速恢复
```
这是当前阶段最适合的方案。
```
```