Skip to content

Commit

Permalink
Config rolling update strategy for operator (#2660)
Browse files Browse the repository at this point in the history
* config-rolling-update-strategy-for-operator

* change doc title

* Update 11.rolling-update-strategy.md

* Update 8.2.pv-reclaim.md

* Update 11.rolling-update-strategy.md
  • Loading branch information
abby-cyber authored Mar 17, 2023
1 parent 6dc6af3 commit 25e9b37
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs-2.0/20.appendix/0.FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ dmp 文件是错误报告文件,详细记录了进程退出的信息,可以

### 防火墙中需要开放哪些端口?

如果没有修改过[配置文件](../5.configurations-and-logs/1.configurations/1.configurations.md) 中预设的端口,请在防火墙中开放如下端口:
如果没有修改过[配置文件](../5.configurations-and-logs/1.configurations/1.configurations.md)中预设的端口,请在防火墙中开放如下端口:

|服务类型|端口|
|-|-|
Expand Down
38 changes: 38 additions & 0 deletions docs-2.0/nebula-operator/11.rolling-update-strategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# NebulaGraph 集群的滚动更新策略

NebulaGraph 集群使用分布式架构将数据分成多个逻辑分片,这些分片通常均分在不同的节点上。分布式系统中,同一份数据通常会有多个副本。为了保证多个副本数据的一致性,NebulaGraph 集群使用 Raft 协议实现了多分片副本同步。Raft 协议中,每个分片都会选举出一个 Leader 副本,Leader 副本负责处理写请求,Follower 副本负责处理读请求。

通过 Operator 创建的 NebulaGraph 集群在滚动更新过程中,一个存储节点会暂时停止提供服务以进行更新。关于滚动更新的概述,参见[执行滚动更新](https://kubernetes.io/zh-cn/docs/tutorials/kubernetes-basics/update/update-intro/)。如果 Leader 副本所在的节点停止提供服务,会导致该分片的读写不可用。为了避免这种情况,Operator 会在 NebulaGraph 集群滚动更新过程中,默认将 Leader 副本迁移到其他未受影响节点上。这样,当一个存储节点处于更新状态时,其他节点上的 Leader 副本能够继续处理客户端请求,以保证集群的读写可用性。

一个存储节点上的所有 Leader 副本全部迁移到其他节点的这个过程可能会持续较长时间。为了更好地控制滚动更新的时间,Operator 提供了一个名为`enableForceUpdate`参数。当确定没有外部访问流量时,可将该参数设置为`true`,这样,Leader 副本将不会被迁移到其他节点上,从而加快滚动更新的速度。

## 滚动更新触发条件

Operator 会在以下情况下触发 NebulaGraph 集群的滚动更新:

- NebulaGraph 集群的版本发生变化。
- NebulaGraph 集群的配置发生变化。

## 配置滚动更新策略

在创建集群实例的 YAML 文件中,添加`spec.storaged.enableForceUpdate`参数,设置为`true``false`,以控制滚动更新的速度。

`enableForceUpdate``true`时,表示不迁移分片 Leader 副本,从而加快滚动更新的速度;反之,表示迁移分片 Leader 副本,以保证集群的读写可用性。默认值为`false`

!!! caution

设置`enableForceUpdate`为`true`时,确保没有流量进入集群进行读写操作。因为该设置会强制重建集群 Pod,此过程会发生数据丢失或客户端请求失败的情况。


配置示例:

```yaml
...
spec:
...
storaged:
enableForceUpdate: true // 设置为 true 时,加快滚动更新的速度。
...
```


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

NebulaGraph Operator 使用持久化卷 PV(Persistent Volume)和持久化卷声明 PVC(Persistent Volume Claim)来存储持久化数据。如果用户不小心删除了一个 NebulaGraph 集群,默认 PV 和 PVC 对象及其数据仍可保留,以确保数据安全。

用户也可以在集群实例的配置文件中通过设置参数`spec.enablePVReclaim``true`来定义在删除集群后自动删除 PVC 以释放数据。至于在删除 PVC 后是否删除 PV,用户需要自定义 PV 的回收策略。参见 [StorageClass 中设置 reclaimPolicy](https://kubernetes.io/docs/concepts/storage/storage-classes/#reclaim-policy)[PV Reclaiming](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming) 了解 PV 回收策略。
用户也可以在集群实例的配置文件中通过设置参数`spec.enablePVReclaim``true`来定义在删除集群后自动删除 PVC 以释放数据。至于在删除 PVC 后是否删除 PV,用户需要自定义 PV 的回收策略。参见 [StorageClass 中设置 reclaimPolicy](https://kubernetes.io/docs/concepts/storage/storage-classes/#reclaim-policy) [PV Reclaiming](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming) 了解 PV 回收策略。


## 前提条件
Expand Down
4 changes: 4 additions & 0 deletions docs-2.0/nebula-operator/9.upgrade-nebula-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@
1 vesoft/nebula-metad:{{nebula.tag}}
3 vesoft/nebula-storaged:{{nebula.tag}}
```

## 加速升级过程

集群的升级过程是一个滚动更新的过程也是耗时的过程,因为 Storage 服务的 Leader 分片副本会进行状态转移。用户可在集群实例的 YAML 文件中配置`enableForceUpdate`参数,来略过 Leader 分片副本转移操作,以达到加速升级的过程。详情参见[配置滚动更新策略](11.rolling-update-strategy.md)。
9 changes: 5 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,16 @@ nav:
- 部署 NebulaGraph:
- 使用 Kubectl 部署 NebulaGraph 集群: nebula-operator/3.deploy-nebula-graph-cluster/3.1create-cluster-with-kubectl.md
- 使用 Helm 部署 NebulaGraph 集群: nebula-operator/3.deploy-nebula-graph-cluster/3.2create-cluster-with-helm.md
- 连接 NebulaGraph: nebula-operator/4.connect-to-nebula-graph-service.md
- 配置 NebulaGraph:
- 自定义 NebulaGraph 集群的配置参数: nebula-operator/8.custom-cluster-configurations/8.1.custom-conf-parameter.md
- 回收 PV: nebula-operator/8.custom-cluster-configurations/8.2.pv-reclaim.md
#ent
- 均衡扩容后的 Storage 数据: nebula-operator/8.custom-cluster-configurations/8.3.balance-data-when-scaling-storage.md
- 升级 NebulaGraph: nebula-operator/9.upgrade-nebula-cluster.md
- 连接 NebulaGraph: nebula-operator/4.connect-to-nebula-graph-service.md
#ent
- 备份与恢复: nebula-operator/10.backup-restore-using-operator.md
- 升级 NebulaGraph: nebula-operator/9.upgrade-nebula-cluster.md
- 配置滚动更新策略: nebula-operator/11.rolling-update-strategy.md
#ent
- 备份与恢复: nebula-operator/10.backup-restore-using-operator.md
- 故障自愈: nebula-operator/5.operator-failover.md
- 常见问题: nebula-operator/7.operator-faq.md

Expand Down

0 comments on commit 25e9b37

Please sign in to comment.