文档版本 v3.7-DRAFT 处于 草稿 状态。如需获取最新的稳定版文档,请参阅 v3.6。
功能开关
本页面概述了管理员可以在 etcd 上指定的各种功能门控。
有关功能各阶段的说明,请参见 功能阶段。
概述
功能门控是一组键值对,用于描述 etcd 的功能。你可以使用 etcd 的 --feature-gates 命令行标志来开启或关闭这些功能。
etcd 允许你启用或禁用一组功能门控。使用 -h 标志可查看完整的功能门控列表。要设置功能门控,请在命令行中使用 --feature-gates 标志并赋值为功能键值对列表:
--feature-gates=...,StopGRPCServiceOnDefrag=true
或者在 YAML 配置文件中指定 feature-gates:
feature-gates: ...,StopGRPCServiceOnDefrag=true
embed.EtcdServer 结构体的变更
在 3.6 版本中,字段 ServerFeatureGate 被添加到 embed.Config 中,并应取代下面列出的实验性字段:
package embed
type Config struct {
// Deprecated: Use CompactHashCheck Feature Gate instead. Will be decommissioned in v3.7.
ExperimentalCompactHashCheckEnabled bool `json:"experimental-compact-hash-check-enabled"`
// Deprecated: Use InitialCorruptCheck Feature Gate instead. Will be decommissioned in v3.7.
ExperimentalInitialCorruptCheck bool `json:"experimental-initial-corrupt-check"`
// Deprecated: Use TxnModeWriteWithSharedBuffer Feature Gate instead. Will be decommissioned in v3.7.
ExperimentalTxnModeWriteWithSharedBuffer bool `json:"experimental-txn-mode-write-with-shared-buffer"`
// Deprecated: Use StopGRPCServiceOnDefrag Feature Gate instead. Will be decommissioned in v3.7.
ExperimentalStopGRPCServiceOnDefrag bool `json:"experimental-stop-grpc-service-on-defrag"`
// Deprecated: Use LeaseCheckpoint Feature Gate instead. Will be decommissioned in v3.7.
ExperimentalEnableLeaseCheckpoint bool `json:"experimental-enable-lease-checkpoint"`
// Deprecated: Use LeaseCheckpointPersist Feature Gate instead. Will be decommissioned in v3.7.
ExperimentalEnableLeaseCheckpointPersist bool `json:"experimental-enable-lease-checkpoint-persist"`
+ // ServerFeatureGate is a server level feature gate
+ ServerFeatureGate featuregate.FeatureGate
...
Alpha 或 Beta 功能的功能门控
下表总结了你可以在 etcd 上设置的功能门控。
| 功能 | 默认值 | 阶段 | 详情 |
|---|---|---|---|
| CompactHashCheck | false | Alpha | 在服务任何客户端/对等节点流量之前启用数据损坏检查。 |
| InitialCorruptCheck | false | Alpha | 启用领导者定期检查跟随者的压缩哈希。 |
| LeaseCheckpoint | false | Alpha | 启用领导者向其他成员发送定期检查点,以防止在领导者变更时重置剩余的 TTL。 |
| LeaseCheckpointPersist | false | Alpha | 启用将剩余 TTL 持久化,以防止长期租约无限自动续期。 |
| SetMemberLocalAddr | false | Alpha | 启用在与对等节点通信时,使用 initial-advertise-peer-urls 中指定的第一个非回环本地地址作为本地地址。 |
| StopGRPCServiceOnDefrag | false | Alpha | 启用在执行碎片整理时停止 etcd gRPC 服务对客户端请求的响应。 |
| TxnModeWriteWithSharedBuffer | true | Beta | 允许写事务在其只读检查操作中使用共享缓冲区。 |
使用功能
功能阶段
一项功能可能处于 Alpha、Beta、GA 或 已弃用 阶段。一个 Alpha 功能表示:
- 默认禁用。
- 可能存在缺陷。启用该功能可能会暴露问题。
- 可能随时在不通知的情况下终止对该功能的支持。
- 该功能的 API 可能在后续软件版本中发生不兼容的变更,且不会提前通知。
- 由于存在缺陷的风险较高且缺乏长期支持,建议仅在短期测试集群中使用。
一个 Beta 功能表示:
- 默认启用。
- 该功能已经过充分测试,启用被认为是安全的。
- 整体功能的支持不会被取消,但细节可能会有所调整。
- 由于更广泛的应用可能导致发现新的、难以察觉的缺陷,因此建议仅用于非关键业务场景。
注意:请务必尝试 Beta 功能并提供反馈!一旦功能退出 Beta 阶段,我们可能很难再进行重大修改。
正式发布(GA)功能也称为 稳定 功能。它表示:
- 该功能始终处于启用状态;您无法将其禁用。
- 相应的功能门控不再需要。
- 稳定版本的功能将在后续多个发布版本中持续存在。
一个 已弃用 的功能表示:
- 该功能门控已不再使用。
- 该功能已升级为 GA 状态或已被移除。